.cpp
Code
C++ 源代码
C++ 是一种强大的系统编程语言,在 C 的基础上扩展了面向对象编程、模板、RAII 和标准模板库(STL)。它被用于游戏引擎、浏览器、数据库、操作系统和高频交易系统。
MIME 类型
text/x-c++src
类型
文本
压缩
无损
优点
- + High performance with zero-cost abstractions
- + Rich standard library (STL) with containers, algorithms, and iterators
- + RAII provides deterministic resource management
- + Templates enable powerful generic programming
缺点
- − Complex language with a very steep learning curve
- − Long compilation times, especially with heavy template use
- − Manual memory management (though smart pointers help)
何时使用 .CPP
在游戏引擎、实时系统、浏览器、数据库以及任何需要高性能和抽象能力的软件中使用 C++。
技术细节
C++ 编译为原生机器码,支持多种范式:过程式、面向对象和泛型(模板)。RAII(资源获取即初始化)通过构造函数和析构函数管理资源。
历史
Bjarne Stroustrup 于 1979 年在贝尔实验室创建了 C++,最初称为「带类的 C」。它于 1998 年标准化(C++98),此后经历了 C++11、C++14、C++17、C++20 和 C++23 的重大现代化演进。