Polyglot
Languages C++
Volume C++

C++

A general-purpose, statically typed, multi-paradigm programming language standardised by ISO/IEC since 1998. Built on a C-compatible substrate with substantial additions for object-oriented programming, generic programming through templates, deterministic resource management via RAII, and a rich standard library.

Paradigms
imperative · OOP · functional
Typing
static
Memory
manual
Version
C++23
First released
1985

C++ is a general-purpose, statically typed, multi-paradigm programming language standardised by ISO/IEC since 1998. The language extends a C-compatible core with classes, templates, exceptions, and a substantial standard library. It supports imperative, object-oriented, and generic programming, with a partial functional style admitted through lambdas and the algorithms library. C++ retains C’s compilation model — translation to native machine code through a compiler and linker, no virtual machine, no garbage collector — and its commitment to “you do not pay for what you do not use”, which manifests as a preference for compile-time mechanisms (templates, constexpr, concepts) over runtime ones. Memory and lifetime management are governed by RAII: the acquisition of a resource is bound to the construction of an object, and its release is performed by the destructor when the object goes out of scope.

History

C++ was developed by Bjarne Stroustrup at Bell Laboratories beginning in 1979, initially as an extension of C named C with Classes. The name C++ was adopted in 1983, in reference to the increment operator of C and the relationship between the two languages. ISO ratified the first standard in 1998 as ISO/IEC 14882:1998, commonly designated C++98; a minor revision followed in 2003 as C++03. C++11 (ISO/IEC 14882:2011) was the largest revision in the language’s history, introducing auto type deduction, lambda expressions, range-based for, rvalue references and move semantics, smart pointers, constexpr, threading primitives, and the <chrono> library. C++14 and C++17 were intermediate revisions: C++14 generalised constexpr and added generic lambdas; C++17 introduced structured bindings, if constexpr, std::optional, std::variant, and parallel algorithms. C++20 was a second large revision, introducing modules, concepts, coroutines, ranges, and the three-way comparison operator. C++23 (ISO/IEC 14882:2024) refined <expected>, <print>, and additional ranges support. The next revision, C++26, is in active development.

Hello world

#include <iostream>

int main() {
    std::cout << "Hello, world!\n";
    return 0;
}

Compilation and execution with a conventional toolchain:

c++ hello.cpp -o hello && ./hello

The identifier c++ is a conventional alias for the system’s default C++ compiler — typically g++ on Linux distributions, clang++ on macOS and the BSDs, and cl.exe, under a distinct command-line interface, on Windows. Selection of a particular language standard is performed through the -std= option (-std=c++23, -std=c++20, and so on); the precise spelling and default vary across implementations.