C++ Anchors Core Infrastructure on Zero-Overhead Performance

C++ in 100 Seconds — Fireship

Fireship

By combining high-level object-oriented abstractions with direct hardware control at zero runtime cost, C++ maintains its dominance across mission-critical systems despite steep memory risks.

AI-assisted summary of C++ in 100 Seconds — original source. Check the original for full context.

Source published:

Key ideas

  • Created in 1979 by Bjarne Stroustrup, C++ combines the object-oriented structure of Simula with the raw, bare-metal speed of C, functioning as a superset with zero-overhead abstractions. (0:00)
  • C++ serves as the bedrock for global software infrastructure, powering AAA game engines like Unreal Engine, desktop software such as Adobe After Effects, major databases like MySQL and MongoDB, and embedded devices. (0:00)
  • The language provides native object-oriented architecture through classes with private-by-default encapsulation, method overloading, inheritance, and automated constructor/destructor lifecycles. (1:06)
  • Modern C++ mitigates historical manual memory pitfalls by incorporating smart pointer utilities such as std::unique_ptr, which guarantee single ownership and automatic resource cleanup. (1:06)

Detailed notes

## Background Published by the channel Fireship on YouTube on February 7, 2022, this video provides a rapid introduction to C++. According to the description, C++ was created in 1979 and remains an extremely popular object-oriented programming language that powers game engines, databases, compilers, embedded systems, desktop software, and core software infrastructure.

## TL;DR C++ originated in 1979 when Bjarne Stroustrup blended Simula's object-oriented paradigms with C's bare-metal performance, creating a language built on zero-overhead abstractions. Renowned for its steep learning curve and unmatched speed, it serves as the foundational engine for game engines like Unreal, creative desktop applications, databases, and embedded microchips. Writing C++ involves compiling code through tools like GCC or Clang, structuring applications inside a mandatory main function, and utilizing modern input/output streams. The language shines through robust object-oriented features like classes, method overloading, and inheritance, while modern standards mitigate manual memory hazards through utilities like smart pointers.

## Atmosphere & style The presentation is trademark Fireship: hyper-fast, irreverent, and dense with punchy technical humor. It balances respect for the foundational power of low-level systems programming with playful jabs at C++'s notorious complexity and memory management pitfalls. Watching it feels like a rapid-fire tour that strips away academic fluff, delivering core programming paradigms and historical context with razor-sharp comedic pacing.

## Bulletin - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) Created in 1979 by Bjarne Stroustrup, C++ combines the object-oriented structure of Simula with the raw, bare-metal speed of C, functioning as a superset with zero-overhead abstractions. - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ serves as the bedrock for global software infrastructure, powering AAA game engines like Unreal Engine, desktop software such as Adobe After Effects, major databases like MySQL and MongoDB, and embedded devices. - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) The language provides native object-oriented architecture through classes with private-by-default encapsulation, method overloading, inheritance, and automated constructor/destructor lifecycles. - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) Modern C++ mitigates historical manual memory pitfalls by incorporating smart pointer utilities such as std::unique_ptr, which guarantee single ownership and automatic resource cleanup.

## Key takeaways - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) Bjarne Stroustrup created C++ at AT&T Bell Labs in 1979, initially naming it 'C with Classes.' - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) The language was designed to combine the clean object-oriented architecture of Simula with the high-performance execution of C. - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ functions essentially as a superset of C, allowing virtually any valid C program to compile and run as C++. - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) A foundational tenet of C++ is 'zero-overhead abstractions,' meaning language features impose no runtime performance penalty if they are not used. - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ is ubiquitous in performance-critical software, powering game engines like Unreal Engine, databases like MySQL and MongoDB, compilers, and embedded devices. - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) The language offers low-level hardware control alongside high-level abstractions, accompanied by a steep learning curve and high consequence for memory errors. - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) C++ source code is written in .cpp files and compiled using native compilers such as GCC or Clang, with execution beginning in a main function. - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) Standard console I/O relies on the <iostream> header, sending text to std::cout using the stream insertion (bitwise shift left) operator. - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) Developers can use legacy C-style character arrays or modern high-level string objects provided by the <string> standard library header. - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) C++ classes enforce encapsulation with members set to private by default unless explicitly placed under the public access specifier. - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) Class methods can be declared inside the class body and defined externally using the scope resolution operator (::). - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) Polymorphism is supported through method overloading, allowing multiple functions with identical names but distinct parameter signatures. - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) Custom constructors and destructors handle setup and teardown logic automatically during object instantiation and destruction. - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) Modern C++ reduces manual pointer bugs through smart pointers like std::unique_ptr, ensuring single ownership and automatic memory deallocation.

## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) Origins, Philosophy, and Where C++ Runs the World

C++ is a statically typed, compiled programming language celebrated for powering core software infrastructure worldwide, while simultaneously infamous among developers for its notoriously steep learning curve. It originated in 1979 when Bjarne Stroustrup created it at AT&T Bell Labs. Stroustrup was inspired by the clean, object-oriented concepts of Simula, but he desperately needed the raw, blistering performance of C. His initial hybrid creation was aptly named "C with Classes." It was architected essentially as a superset of C, meaning virtually any valid C program can compile and run as a C++ program. Crucially, C++ introduces "zero-overhead abstractions"—features that cost nothing in runtime performance if you do not use them—bringing foundational object-oriented paradigms like polymorphism, encapsulation, and inheritance directly into systems programming.

Because it offers direct low-level control over memory and bare-metal hardware alongside high-level abstractions like classes and smart pointers, C++ has become the default engine behind memory-constrained, performance-critical systems. The ecosystem is ubiquitous across the modern software stack: - **Game Development:** Powers AAA title foundations such as the Unreal Engine. - **Creative Software:** Heavyweight desktop applications like Adobe After Effects (used to edit Fireship's own videos). - **Databases:** Relational and NoSQL storage engines like MySQL and MongoDB. - **Embedded Hardware:** Constrained devices down to the microchip driving the display on a smart toaster. - **Foundational Infrastructure:** Low-level developer tooling, including third-party language compilers and virtual machines.

As the famous industry adage puts it: "C++ makes it harder to shoot yourself in the foot, but when you do, it'll blow your whole leg off."

```mermaid flowchart TD accTitle: The Evolution and Philosophy of C++ accDescr: Diagram illustrating how Simula and C influenced C++ and its modern applications.

subgraph Origins ["Language Origins (1979)"] A["Simula<br/>(Object-Oriented Design)"] B["C Language<br/>(Raw Hardware Performance)"] end

subgraph Core ["C++ Core Philosophy"] C["C with Classes / C++"] D["Zero-Overhead Abstractions<br/>(Inheritance, Encapsulation, Polymorphism)"] end

subgraph Uses ["Real-World Systems"] E["Unreal Engine & AAA Games"] F["Databases (MySQL, MongoDB)"] G["Compilers & Virtual Machines"] H["Embedded Systems & Desktop Apps"] end

A --> C B --> C C --> D D --> E D --> F D --> G D --> H ```

---

[01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) Syntax Basics, Object-Oriented Features, and Modern Memory Management

Getting started with C++ begins by installing a native compiler such as GCC or Clang and setting up a source file ending in the `.cpp` extension. Every C++ program begins its execution inside a mandatory `main` function. To handle basic input and output, developers include the `<iostream>` header from the standard library. Printing a classic `"Hello World"` to the terminal involves sending a string literal to the standard character output stream (`std::cout`) using the bitwise shift left operator (`<<`). To avoid constantly prepending `std::` to standard types and utilities, a namespace declaration (`using namespace std;`) can be included at the top of the source file. For handling text, strings can be declared the old-fashioned C way as raw character arrays, or developers can include `<string>` from the standard library to access the modern, high-level `string` type.

The fundamental superpower of C++ lies in its native support for object-oriented programming via classes. A class acts as a blueprint for an object, housing attributes and methods that are private by default. Members can be exposed to the outside world by placing them beneath the `public` access specifier. C++ provides flexible syntax, allowing methods to be declared inside a class and implemented externally using the scope resolution operator (`::`). It supports method overloading—defining the same method name multiple times with differing parameter signatures—which functions as a core mechanism of polymorphism. Lifecycle logic is handled through custom constructors and destructors, which trigger automatic execution whenever an object is instantiated or destroyed. Furthermore, inheritance lets classes reuse and extend shared logic across an application. Instantiating an object is as simple as specifying the class name, the object variable name, and any required constructor arguments.

When handling memory, developers historically wrestled with raw pointers and reference semantics manually. Modern C++ dramatically mitigates potential memory pitfalls by offering smart pointer utilities like `std::unique_ptr`, which guarantees that only one reference can own a particular allocated memory block, automatically freeing the resources when it goes out of scope. Once the code is written, running the application simply requires compiling it directly from the terminal with a tool like `clang++`.

## Notable quotes > [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C with Classes

> [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) zero-overhead abstractions

> [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ makes it harder to shoot yourself in the foot, but when you do, it'll blow your whole leg off.

> [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) main

> [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) <iostream>

> [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) Hello World

> [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) std::cout

> [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) using namespace std;

> [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) public

> [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) std::unique_ptr

## Mentioned Adobe After Effects, AT&T Bell Labs, Bjarne Stroustrup, C, C++, Clang, GCC, MongoDB, MySQL, Simula, Unreal Engine

## Video description C++ or C-plus-plus or Cpp is an extremely popular object-oriented programming language. Created in 1979, today it powers game engines, databases, compilers, embedded systems, desktop software, and much of our software infrastructure.

#programming #compsci #100SecondsOfCode

🔗 Resources

Microsoft Docs https://docs.microsoft.com/en-us/cpp/ Bjarne Stroustrup Homepage https://www.stroustrup.com/ C in 100 Seconds https://youtu.be/U3aXWizDbQ4 C# in 100 Seconds https://youtu.be/ravLFzIguCM

🔥 Get More Content - Upgrade to PRO

Upgrade to Fireship PRO at https://fireship.io/pro Use code lORhwXd2 for 25% off your first payment.

🎨 My Editor Settings

- Atom One Dark - vscode-icons - Fira Code Font

🔖 Topics Covered

- What is C++? - C++ basics tutorial - Who invented C++? - What is C++ used for? - What is a smart pointer? - C++ vs C - Object oriented programming basics

[Source](https://www.youtube.com/watch?v=MNeX4EGtR5Y)

中文简报

C++以零开销性能筑牢核心基础设施 通过将高级面向对象抽象与零运行时开销的直接硬件控制相结合,尽管面临严峻的内存风险,C++依然在关键任务系统中保持主导地位。 C++起源于1979年,由Bjarne Stroustrup将Simula的面向对象范式与C语言的裸机性能相融合,开创了一种基于零开销抽象的语言。C++以陡峭的学习曲线和无与伦比的速度著称,是Unreal等游戏引擎、创意桌面应用、数据库以及嵌入式微芯片的底层核心引擎。编写C++代码涉及通过GCC或Clang等工具进行编译,在必选的main函数中构建应用程序结构,并利用现代输入/输出流。该语言凭借类、方法重载和继承等强大的面向对象特性表现优异,而现代标准则通过智能指针等实用工具缓解了手动内存管理的风险。 C++由Bjarne Stroustrup于1979年创建,将Simula的面向对象结构与C语言纯粹的裸机速度相结合,是具有零开销抽象特性的超集。 (0:00) C++是全球软件基础设施的基石,为Unreal Engine等3A级游戏引擎、Adobe After Effects等桌面软件、MySQL和MongoDB等主流数据库以及嵌入式设备提供支持。 (0:00) 该语言通过默认私有的类封装、方法重载、继承以及构造函数/析构函数的自动化生命周期,提供了原生面向对象架构。 (1:06) 现代C++通过引入std::unique_ptr等智能指针工具来缓解以往手动内存管理的隐患,此类工具可确保单一所有权并实现自动资源清理。 (1:06)

Reading summary

Created in 1979 by Bjarne Stroustrup, C++ bridges the high-level object-oriented architecture of Simula with the bare-metal performance of C, enabling zero-overhead abstractions across foundational computing systems. Origins and the Zero-Overhead Abstraction Principle (0:00) C++ originated at AT&T Bell Labs in 1979 under the working title "C with Classes." Bjarne Stroustrup sought to unite the clear object-oriented structure of Simula with the raw execution speed of C. Built fundamentally as an extension and superset of C, the language permits almost any valid C program to compile and run within its environment. A central tenet of the language is its commitment to "zero-overhead abstractions." Features such as encapsulation, inheritance, and polymorphism are engineered to incur no runtime performance penalties if they are not actively utilized. This design philosophy enables developers to write expressive, structured code without sacrificing bare-metal speed. Ubiquitous Footprint Across Performance-Critical Software (0:00) Because C++ provides granular, low-level control over hardware and memory alongside high-level abstractions, it serves as the industry standard for memory-constrained and latency-sensitive platforms. Its footprint spans game development platforms such as the Unreal Engine, creative desktop software like Adobe After Effects, and database engines including MySQL and MongoDB. Beyond enterprise software, C++ underpins foundational developer infrastructure, such as language compilers and virtual machines, as well as embedded hardware running on resource-constrained microchips. While celebrated for its raw utility, this extensive low-level access historically contributed to a steep learning curve, illustrated by the industry adage that mistakes in C++ carry disproportionately severe consequences for system stability. Object-Oriented Mechanics and Modern Memory Control (1:06) A C++ program executes from a standard `main` function, leveraging native standard library headers like `<iostream>` for terminal stream output and `<string>` for high-level text manipulation. Object-oriented features rely on classes, whose members remain private by default unless exposed via the `public` specifier. Logic can be implemented externally using the scope resolution operator (`::`), while method overloading supplies polymorphic behavior, and automatic constructors and destructors manage object lifecycles. To address historical vulnerabilities tied to manual pointer arithmetic and raw references, modern C++ introduces automated memory utilities. Features like `std::unique_ptr` enforce exclusive ownership over allocated memory blocks, automatically reclaiming resources when they fall out of scope without manual deallocation. While C++ retains a reputation for complexity and high-stakes error handling, modern language standards and abstractions like smart pointers mitigate historical memory pitfalls without compromising its foundational runtime efficiency.

Detailed notes — zh

## Background 该视频由技术科普频道 Fireship 于 2022 年 2 月 7 日发布在 YouTube 平台。视频简介将其定位为“100 秒代码”系列,旨在快速介绍 C++ 这门诞生于 1979 年、极具人气的面向对象编程语言,并概述其在游戏引擎、数据库、编译器以及底层基础设施中的广泛应用。 ## TL;DR 视频首先回顾了比雅尼·斯特劳斯特鲁普(Bjarne Stroustrup)在贝尔实验室结合 Simula 面向对象特性与 C 语言极致性能而打造 C++ 的历史,并盘点了它在虚幻引擎、数据库和嵌入式系统等关键领域的核心地位。随后,内容迅速转向语法实操,系统讲解了程序入口 `main` 函数、基于 `<iostream>` 的控制台输出以及 `std::string` 的使用方式。最后,视频提炼了 C++ 面向对象编程的核心机制(包括类封装、作用域解析符、函数重载、构造与析构函数)以及如何借助现代智能指针(如 `unique_ptr`)进行安全高效的内存管理与编译。 ## Atmosphere & style 视频延续了 Fireship 标志性的快节奏与幽默风格,语速飞快且信息密度极高,如同在科技梗与硬核代码之间进行的一场脑力竞速。画风犀利而干练,在密集的语法展示中穿插着诸如“搬起石头砸整条腿”等极具反差感的开发者自嘲。整段内容让人感觉紧凑、通透又充满科技极客的活力,将原本以复杂晦涩著称的 C++ 梳理得既生动有趣又举重若轻。 ## Bulletin - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ 由 Bjarne Stroustrup 于 1979 年在贝尔实验室基于 Simula 与 C 语言融合创立,以 C 语言超集身份引入了具备零开销抽象的面向对象体系。 - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) 作为现代软件基础设施的支柱,C++ 广泛驱动着虚幻引擎、专业音视频软件、主流数据库、编译器虚拟机以及各类嵌入式系统。 - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 语言在语法上完整支持基于类的面向对象编程,涵盖访问修饰控制、外部作用域解析、函数重载以及生命周期构造与析构管理。 - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 除传统的原始指针外,现代 C++ 提供了如 std::unique_ptr 等智能指针方案,在兼顾底层控制力的同时显著降低了手动管理内存的风险。 ## Key takeaways - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ 是一门静态类型、编译型的编程语言,以其对底层软硬件的直接控制力和陡峭的学习曲线著称。 - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) Bjarne Stroustrup 于 1979 年在 AT&T 贝尔实验室研发了该语言的前身“带类的 C”(C with Classes)。 - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) 该语言的设计初衷是将 Simula 的面向对象特性与 C 语言无与伦比的高性能结合起来。 - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) 作为 C 语言的超集,几乎所有合法的 C 语言程序均可直接作为有效的 C++ 代码运行。 - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ 贯彻“零开销抽象”原则,在实现封装、继承与多态等特性的同时不会带来额外的运行时性能损耗。 - [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ 是众多高性能与关键基础设施的核心技术选型,包括虚幻引擎、Adobe After Effects、MySQL、MongoDB 及各类底层虚拟机和编译器。 - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 标准 C++ 程序以 .cpp 为文件扩展名,以 main 函数作为执行入口,并依赖 <iostream> 标准库进行输入输出交互。 - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 标准库提供了 <string> 等功能完备的高级抽象类型,简化了传统 C 风格字符数组的复杂处理。 - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 类成员在 C++ 中默认具备 private 访问权限,对外暴露的接口必须显式声明在 public 作用域下。 - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 开发者可以使用双冒号作用域解析运算符(::)将成员函数的具体业务实现剥离到类体外部编写。 - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 方法重载(Overloading)允许相同名称的函数接受不同的参数列表,构成了编译期多态的关键机制。 - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 通过定义构造函数(Constructor)与析构函数(Destructor),开发者可以在对象的创建与销毁阶段精确介入生命周期控制与资源释放。 - [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 现代 C++ 引入了诸如 std::unique_ptr 等智能指针,通过排他性持有和自动销毁机制有效防范了内存泄漏问题。 ## Detailed walkthrough ### [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ 的诞生、演进与应用生态 C++ 是一门静态类型、编译型的编程语言。它因在底层软件基础设施中的广泛应用而闻名遐迩,同时也因其极其陡峭的学习曲线而“臭名昭著”。这门语言由比雅尼·斯特劳斯特鲁普(Bjarne Stroustrup)于 1979 年在 AT&T 贝尔实验室(Bell Labs)打造。当时,斯特劳斯特鲁普深受 Simula 语言面向对象特性的启发,但他同时迫切需要一种拥有 C 语言极致高性能的工具,于是“带类的 C”(C with Classes)便应运而生。C++ 在设计上被定位为 C 语言的超集(superset),这意味着几乎任何合法的 C 语言程序都可以直接作为有效的 C++ 程序运行。在此基础上,它引入了多态(polymorphism)、封装(encapsulation)以及继承(inheritance)等面向对象设计模式,同时贯彻了严格的“零开销抽象”(zero-overhead abstractions)原则。 如今,C++ 活跃在各色对内存有严苛限制与极致性能要求的系统中。从用于制作 3A 级大作的虚幻引擎(Unreal Engine),到用于剪辑本期视频的专业后期软件 Adobe After Effects;从 MySQL 和 MongoDB 等主流数据库引擎,到智能烤面包机屏幕上运行的嵌入式系统;乃至编程语言编译器与虚拟机等底层基础设施,背后都有 C++ 的身影。这门语言之所以长盛不衰,核心原因在于它兼具了类似 C 语言操纵底层内存和硬件的控制力,以及类(Classes)和智能指针(Smart Pointers)等高级抽象手段。正如那句调侃所言:“C++ 让你更难搬起石头砸自己的脚,但一旦砸中,它会直接轰掉你整条腿”("C++ makes it harder to shoot yourself in the foot, but when you do, it'll blow your whole leg off")。 ```mermaid flowchart TD accTitle: C++ 技术架构与应用谱系 accDescr: 展示 C++ 从底层特性到高级抽象及其覆盖的应用场景架构图 subgraph Core["底层控制与起源"] C["C 语言底色<br/>硬件与内存直接操作"] Simula["Simula 语言<br/>面向对象概念启发"] end subgraph Abs["C++ 零开销抽象"] OOP["面向对象特性<br/>封装 · 继承 · 多态"] Modern["现代管理工具<br/>类 · 智能指针 (unique_ptr)"] end subgraph Apps["关键应用领域"] Infra["基础设施<br/>编译器 / 虚拟机 / 数据库"] Perf["高性能场景<br/>虚幻引擎 3A 游戏 / 视音频制作"] Embed["受限环境<br/>嵌入式智能设备"] end C --> OOP Simula --> OOP OOP --> Modern Modern --> Infra Modern --> Perf Modern --> Embed ``` - **诞生年份与机构**:1979 年由 Bjarne Stroustrup 在 AT&T Bell Labs 发明,前身为“C with Classes”。 - **语言特性**:静态类型、编译型、C 语言超集、零开销抽象(封装、继承、多态)。 - **代表性应用**:虚幻引擎(Unreal Engine)、Adobe After Effects、MySQL、MongoDB、语言编译器与虚拟机、智能烤面包机等嵌入式设备。 --- ### [01:06](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=66s) 语法实操:从 Hello World 到面向对象与智能指针 要上手编写 C++,开发者首先需要安装一个现代 C++ 编译器,例如 GCC 或 Clang。新建一个以 `.cpp` 结尾的文件后,首先需要引入标准库中的 `<iostream>` 头文件以支持输入输出操作。程序的执行起点永远是 `main` 函数。若要输出经典的 "Hello World",只需调用标准字符输出对象 `std::cout`,后接按位左移运算符 `<<` 以及目标字符串字面量即可。如果觉得每次都要写 `std::` 太过繁琐,也可以在文件顶部加入 `using namespace std;` 命名空间声明来予以省略。在变量定义方面,虽然开发者依然可以像 C 语言那样使用字符数组来定义字符串,但只要引入标准库中的 `<string>` 头文件,便能直接享用功能完备的 `string` 类型。 真正颠覆开发体验的是 C++ 对基于类(class)的面向对象编程的完整支持。类本质上就是对象的蓝图。在类内部,你可以自由声明属性(成员变量)和方法(成员函数)。类内的成员默认均为私有(`private`),如果需要对外开放,则必须置于 `public` 访问修饰符下方。除了在类体内编写实现,开发者还可以利用双冒号作用域解析运算符(`::`)在类体外部单独定义方法逻辑。不仅如此,C++ 允许使用相同的名称但不同的参数列表来重复定义方法,这种被称为“重载”(overloading)的技术正是多态的一种体现。通过定义构造函数(Constructor)与析构函数(Destructor),开发者可以在对象创建或销毁的生命周期节点精确触发自定义代码;而通过类继承机制,多个对象之间能够以极高的效率共享业务逻辑。 创建对象实例非常直观:只需写下类名,紧跟对象变量名,并按需传入构造函数参数即可完成实例化。至于最具挑战性的内存管理领域,开发者既可以选择使用传统的原始指针(pointers)和引用(references)进行全手动管理,也可以利用现代 C++ 提供的 `std::unique_ptr` 等智能指针工具。智能指针能以更简单、更安全的方式接管内存,确保同一块内存在同一时刻只能被单个对象排他性持有并自动释放。完成代码编写后,在终端中直接运行类似 `clang++` 的编译命令即可将其编译为可执行文件,完成从代码到原生二进制程序的全流程。 - **基础语法规范**:源文件扩展名为 `.cpp`,程序入口为 `int main()`,控制台输出使用 `<iostream>` 中的 `cout` 与流插入符 `<<`。 - **面向对象核心概念**: - 类成员默认访问级别为 `private`,需显式声明 `public:`。 - 支持使用作用域解析符 `::` 将函数实现分离在类外部。 - 函数重载(Overloading):同名方法接受不同参数,实现编译期多态。 - 生命周期钩子:通过构造函数(Constructor)初始化,通过析构函数(Destructor)处理销毁与资源清理。 - **内存与工具链**:除了传统指针与引用,推荐使用现代智能指针(如 `unique_ptr`)避免内存泄漏;可直接使用终端工具 `clang++` 进行编译构建。 ## Notable quotes > [00:00](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=0s) C++ is a statically typed, compiled programming language famous for its use in software infrastructure, but infamous for its steep learning curve. > [00:12](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=12s) He took inspiration from the Simula language, which had object-oriented features, but Stroustrup desperately needed the extreme high performance of the C language. > [00:20](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=20s) And the result was C with Classes. > [00:24](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=24s) It was designed as a superset of C, meaning virtually any valid C program is also a valid C++ program. > [00:31](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=31s) It introduced object-oriented design patterns like polymorphism, encapsulation, and inheritance, all while maintaining the philosophy of zero-overhead abstractions. > [00:58](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=58s) C++ makes it harder to shoot yourself in the foot, but when you do, it'll blow your whole leg off. > [01:31](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=91s) Now, the real power of C++ comes from its support for object-oriented programming with classes. > [01:38](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=98s) By default, properties and methods are private, but they can be made public with the public keyword. > [01:48](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=108s) We can define a method with the same name multiple times with different parameters to overload it. > [02:13](https://www.youtube.com/watch?v=MNeX4EGtR5Y&t=133s) To manage memory, you can use pointers and references like you would in C, but modern C++ provides tools like unique pointers to make memory management simpler and safer. ## Mentioned C++, Bjarne Stroustrup, AT&T Bell Labs, Simula, C, Unreal Engine, Adobe After Effects, MySQL, MongoDB, GCC, Clang, clang++ ## Video description C++ or C-plus-plus or Cpp is an extremely popular object-oriented programming language. Created in 1979, today it powers game engines, databases, compilers, embedded systems, desktop software, and much of our software infrastructure. #programming #compsci #100SecondsOfCode 🔗 Resources Microsoft Docs https://docs.microsoft.com/en-us/cpp/ Bjarne Stroustrup Homepage https://www.stroustrup.com/ C in 100 Seconds https://youtu.be/U3aXWizDbQ4 C# in 100 Seconds https://youtu.be/ravLFzIguCM 🔥 Get More Content - Upgrade to PRO Upgrade to Fireship PRO at https://fireship.io/pro Use code lORhwXd2 for 25% off your first payment. 🎨 My Editor Settings - Atom One Dark - vscode-icons - Fira Code Font 🔖 Topics Covered - What is C++? - C++ basics tutorial - Who invented C++? - What is C++ used for? - What is a smart pointer? - C++ vs C - Object oriented programming basics [Source](https://www.youtube.com/watch?v=MNeX4EGtR5Y)

Source quotes

[0:00] C++ is a statically typed, compiled programming language famous for its use in software infrastructure, but infamous for its steep learning curve. [0:12] He took inspiration from the Simula language, which had object-oriented features, but Stroustrup desperately needed the extreme high performance of the C language. [0:20] And the result was C with Classes. [0:24] It was designed as a superset of C, meaning virtually any valid C program is also a valid C++ program. [0:31] It introduced object-oriented design patterns like polymorphism, encapsulation, and inheritance, all while maintaining the philosophy of zero-overhead abstractions. [0:58] C++ makes it harder to shoot yourself in the foot, but when you do, it'll blow your whole leg off. [1:31] Now, the real power of C++ comes from its support for object-oriented programming with classes. [1:38] By default, properties and methods are private, but they can be made public with the public keyword. [1:48] We can define a method with the same name multiple times with different parameters to overload it. [2:13] To manage memory, you can use pointers and references like you would in C, but modern C++ provides tools like unique pointers to make memory management simpler and safer.

Source quotes

[0:00] C with Classes [0:00] zero-overhead abstractions [0:00] C++ makes it harder to shoot yourself in the foot, but when you do, it'll blow your whole leg off. [1:06] main [1:06] <iostream> [1:06] Hello World [1:06] std::cout [1:06] using namespace std; [1:06] public [1:06] std::unique_ptr

Original transcript

[0:00] C++ a statically typed compiled [0:03] programming language famous for its [0:04] widespread use in software [0:05] infrastructure and Infamous for its [0:07] steep learning curve it was created in [0:09] 1979 by bej Strauss at AT&T Bell Labs he [0:13] was inspired by the object-oriented [0:15] nature of simula but needed a language [0:17] with a high performance of c and thus C [0:19] with classes was born it's designed as a [0:21] suet of C which means that virtually any [0:24] c program is also a valid C++ program [0:27] but it also adds zero overhead [0:28] abstractions such as object-oriented [0:30] patterns like polymorphism encapsulation [0:33] and inheritance today it's used in a [0:35] wide variety of systems with constrained [0:37] memory demands like the Unreal Engine [0:38] for AAA video games programs like Adobe [0:41] After Effects that were used to edit [0:42] this video databases like MySQL and [0:45] mongodb embedded systems like the [0:47] display on your smart toaster and is [0:48] used to implement much of our low-level [0:50] infrastructure like language compilers [0:52] and virtual machines it's so popular [0:54] because it provides low-level memory and [0:55] Hardware control like C but with highle [0:58] abstractions like classes and Mark [1:00] pointers C++ makes it harder to shoot [1:02] yourself in the foot but when you do [1:03] it'll blow your whole leg off to get [1:06] started install a C+ plus compiler like [1:09] GCC or clang then create a file ending [1:11] in CPP include IO stream from the [1:13] standard library to handle input and [1:15] output your code will start executing [1:17] from the main function to print hello [1:19] world we simply use standard character [1:20] output followed by the bit y shift left [1:22] operator and a string literal we can get [1:24] rid of this STD though by adding a [1:26] namespace to the top of the file now if [1:28] we want to create a string variable we [1:30] can do so by typing it as an array of [1:32] characters however if we include string [1:34] from the standard Library we can use the [1:36] string type instead the real game [1:38] changer though is the fact that C++ [1:40] supports object-oriented programming [1:41] with classes a class is just a blueprint [1:44] for an object inside a class you can [1:46] Define attributes and methods that will [1:47] be private by default or make them [1:49] public by adding them under the public [1:51] specifier it's also possible to Define [1:53] methods outside the class definition [1:55] using a double colon methods can also be [1:57] defined multiple times with different [1:58] parameters which is known as overloading [2:01] and is a form of polymorphism in [2:02] addition we can Define Constructors and [2:04] destructors to run code when an object [2:06] is created or destroy classes also [2:09] support inheritance allowing developers [2:10] to more efficiently share logic [2:12] throughout a program to instantiate an [2:14] object type the class name followed by [2:15] the name of your object and optionally [2:17] any parameters for the Constructor when [2:19] it comes to memory we could manage [2:21] everything manually with pointers and [2:22] references however tools like unique [2:24] pointer can get the job done in a way [2:26] that's easier and safer by ensuring that [2:28] only one object can be allocated to [2:30] memory now to run your code open up the [2:32] terminal and use a tool like clang ++ to [2:34] compile it this has been C++ in 100 [2:38] seconds hit the like button and [2:39] subscribe if you want to see more short [2:41] videos like this thanks for watching and [2:43] I will see you in the next one