C++
| Technology | |
|---|---|
![]() Image placeholderPlace the file shown below in the assets/articles folder cpp.webp | |
| Designer | Bjarne Stroustrup |
| First appeared | 1985 (as C with Classes, 1979) |
| Paradigm | Multi-paradigm: procedural, object-oriented, generic, functional |
| Typing | Static, partly strong |
| Standard | ISO/IEC 14882 (latest published: C++23) |
C++ is a general-purpose, statically typed programming language that extends C with classes, templates, exceptions and a large standard library.[1] Its central design goal is to provide high-level abstractions without extra runtime cost, a principle often called zero-overhead abstraction: what you do not use, you do not pay for.
C++ is used where performance and control over hardware matter, including game engines, web browsers, databases, financial trading systems, compilers and embedded software.
History
Bjarne Stroustrup began working on "C with Classes" in 1979 at Bell Labs, inspired by the class concept of Simula, which he had used for his doctoral work. He wanted Simula's organisation for large programs together with the speed of C. The language was renamed C++ in 1983, a pun on the C increment operator.[1]
The first commercial release came in 1985, together with the book The C++ Programming Language. Features such as multiple inheritance, templates and exceptions followed in the late 1980s and early 1990s. The Standard Template Library, designed by Alexander Stepanov, was incorporated into the language during standardisation.
Standards
The first ISO standard, C++98, was published in 1998. After a minor update in 2003, the large C++11 revision modernised the language. Since 2011 the committee has released a new version roughly every three years.[2]
| Version | Year | Notable features |
|---|---|---|
| C++98 | 1998 | First ISO standard, STL, templates, exceptions |
| C++11 | 2011 | auto, lambdas, move semantics, nullptr, threads, smart pointers |
| C++14 | 2014 | Generic lambdas, return type deduction |
| C++17 | 2017 | Structured bindings, std::optional, std::filesystem, parallel algorithms |
| C++20 | 2020 | Concepts, ranges, coroutines, modules |
| C++23 | 2023 | std::expected, std::print, deducing this |
The standard is published as ISO/IEC 14882. Work on C++26 is the next step.
Core features
Classes and objects. A class bundles data with functions and controls access with public, protected and private. C++ supports inheritance and virtual functions for runtime polymorphism.
Templates. Templates generate code for many types at compile time. They power the standard containers and algorithms and allow generic programming without runtime overhead.
RAII. Resource Acquisition Is Initialization ties the lifetime of a resource such as memory, a file or a lock to an object. When the object goes out of scope its destructor releases the resource, even if an exception is thrown. This replaces the manual free calls required in C.
Standard library. It provides containers such as std::vector and std::map, algorithms, strings, streams, threads and smart pointers.
#include <iostream>
#include <memory>
#include <vector>
int main() {
std::vector<int> v{3, 1, 2};
auto p = std::make_unique<int>(42); // freed automatically
for (int x : v) std::cout << x * *p << ' ';
std::cout << '\n';
}Memory management
C++ has no garbage collector. Objects live on the stack or on the heap, and the programmer controls their lifetime. Modern C++ discourages raw new and delete in favour of std::unique_ptr, std::shared_ptr and containers, which make ownership explicit. Move semantics, introduced in C++11, let programs transfer resources between objects instead of copying them.
Compilers and tooling
The main implementations are GCC, Clang (part of the LLVM project) and Microsoft's MSVC. Build systems such as CMake and package managers such as vcpkg and Conan are widely used to manage projects. Because C++ compiles ahead of time to machine code, programs run without a virtual machine.
Criticism and safety
C++ is often criticised for its size and complexity. Decades of added features mean the language has many ways to do the same thing, and long template error messages are notorious. Like C, it permits undefined behaviour such as out-of-bounds access and use-after-free errors, which are a major source of security vulnerabilities. In response, the community promotes guidelines such as the C++ Core Guidelines, static analysis and hardened standard library modes. Languages such as Rust compete in some of the same domains with a stricter safety model.
Relationship to C
C++ was designed to be largely compatible with C, and it can call C libraries directly. They are nonetheless distinct languages with different standards. Writing C code and compiling it as C++ can fail, and idiomatic C++ differs substantially from idiomatic C.
Use today
C++ powers many well-known systems: browser engines, game engines such as Unreal, the LLVM compiler infrastructure, machine learning runtimes and many parts of operating systems and office software. It remains a mainstay of high-performance computing and of any domain where predictable speed and low-level control are needed.
Performance, abstraction and compatibility
C++ aims to let programmers use high-level abstractions without requiring a virtual machine or managed runtime for every operation. Templates, inline functions and compile-time evaluation allow reusable components to be specialised by the compiler. The standard library provides containers, algorithms, strings, smart pointers, concurrency primitives and other facilities that reduce the need for handwritten low-level code.
The language's evolution also means that old and new styles often coexist in the same codebase. Modern C++ encourages resource-acquisition-is-initialisation (RAII), move semantics and standard-library types that make ownership clearer. Legacy code may use manual memory management and older conventions. Large projects need consistent guidelines because the language offers many ways to express similar operations.
C++ is not automatically safer or faster than every alternative. Performance depends on algorithms, data layout, compiler settings and hardware. Its broad feature set can increase build times and make interfaces difficult to understand. The language is most effective when a project benefits from fine control and reusable abstractions and has the engineering capacity to manage its complexity.
Editorial connections and engineering implications
Object lifetime and resource management
C++ has grown from an extension of C into a language with templates, exceptions, modules and a large standard library. Its object model defines storage duration, object lifetime and value categories, all of which matter when code manages resources without a tracing garbage collector. The Resource Acquisition Is Initialization (RAII) idiom links a resource's lifetime to an object's lifetime: a constructor acquires it and a destructor releases it when the object leaves scope.
Smart pointers, containers, locks and file wrappers use RAII to make cleanup predictable, including when exceptions occur. Templates enable reusable abstractions and concepts can constrain the types accepted by generic code, but advanced template usage can increase compilation complexity. C++ remains useful for performance-critical applications and large existing systems. C offers a smaller language and broad ABI support, while Rust enforces additional memory-safety rules in safe code. Choosing among them depends on toolchains, existing code, team expertise and reliability requirements.
See also
- C (programming language) – A general-purpose, statically typed systems programming language created at Bell Labs in the early 1970s.
- Rust – A compiled systems programming language that enforces memory safety through ownership and borrowing without a garbage collector.
- Garbage Collection – Automatic memory management in which a runtime reclaims memory that a program can no longer reach.
- WebAssembly – A portable binary instruction format that runs at near-native speed in browsers and other runtimes.
- Grace Hopper – American computer scientist and United States Navy rear admiral who developed an early compiler.
- Python – A high-level, dynamically typed programming language that emphasises readability.
- TypeScript – A language that extends JavaScript with a static type system and compiles to ordinary JavaScript.
- Dennis Ritchie – American computer scientist who created the C programming language and co-created Unix.
References
- ↑ Stroustrup (1993), A History of C++: 1979-1991 (stroustrup.com)
- ↑ Standard C++ Foundation, The C++ standard (isocpp.org)
- ↑ cppreference.com, C++ language (en.cppreference.com)
