EMZETT.
Login

C++

In short: A compiled, object-oriented extension of C with manual memory management and very high execution speed.

In more detail: Gives the programmer direct control over memory (pointers, manual allocation/freeing), which brings performance advantages but also opens up sources of bugs like memory leaks or buffer overflows. Typically used where speed is critical: operating systems, game engines, embedded systems.

In Depth

Object orientation beyond C

Unlike C, C++ (developed from 1979 by Bjarne Stroustrup, originally as “C with classes”) brings object-oriented concepts (classes, inheritance, polymorphism), but leaves the developer the choice of how close to the hardware to stay — you can program in C style with raw pointers as well as use modern, safer constructs like smart pointers, which automatically free memory as soon as it’s no longer needed:

// Classic C style: manual memory management
int* number = new int(42);
delete number; // forget this and you get a memory leak
 
// Modern C++ style: smart pointer
std::unique_ptr<int> number2 = std::make_unique<int>(42);
// automatically freed once "number2" goes out of scope
 
class Vehicle {
public:
    virtual void accelerate() = 0; // pure virtual function
};

Manual memory management as a double-edged sword

Manual memory management means: the developer explicitly decides when memory is allocated (new) and freed again (delete) — unlike languages with automatic garbage collection like Java or C#. This allows maximum control and predictability (no unpredictable GC pause in the middle of a time-critical operation), but also opens up classic sources of bugs: forget delete and a memory leak occurs (memory is never freed); accidentally access memory after delete (“use-after-free”) and it leads to undefined behaviour and potential security vulnerabilities. Modern C++ standards (C++11 and newer) mitigate this risk with smart pointers, which automatically handle freeing without giving up manual control entirely.

Use cases

This mix of maximum control and optional safety mechanisms makes C++ the preferred language for areas where performance is non-negotiable:

  • Game engines: Unreal Engine and most AAA titles, where every millisecond of render time counts.
  • Browser engines: Chrome’s V8 (JavaScript engine) and Blink (rendering engine) are largely C++.
  • Operating systems and drivers: many operating-system components and hardware drivers.
  • Financial systems: high-frequency trading, where microsecond-level latency decides profit or loss.
  • Embedded systems: where resources (memory, computing power) are severely limited.

The price for this control is one of the steepest learning curves among widespread languages — concepts like pointer arithmetic, references, move semantics and template metaprogramming are considered demanding even among experienced developers.

RAII as a central idiom

A central C++ idiom is RAII (“Resource Acquisition Is Initialization”): resources (memory, file handles, network connections) are tied to the lifetime of an object — acquired in the constructor, automatically released in the destructor as soon as the object leaves its scope. This systematically prevents forgotten releases, even if an exception is thrown in the middle, and is the conceptual basis of smart pointers.

See also: C#, Java, C