Programming languages

C++

A powerful compiled language with manual memory control: game engines, browsers, databases and embedded systems.

What it is

Bjarne Stroustrup created C++ as an extension of C with classes, with a first commercial release in 1985. The language is ISO-standardized, and a new edition ships every three years (C++11, 14, 17, 20, 23).

It follows the zero-cost abstraction principle: high-level constructs (templates, RAII, classes) compile to fast machine code. The price is complexity and responsibility for memory.

C++ underlies game engines (Unreal), browsers (Chrome), databases (MySQL, ClickHouse), compilers and real-time systems. Modern C++ prefers smart pointers and RAII over new / delete.

Use it when

  • Maximum performance and resource control: games, engines, graphics.
  • Systems programming, drivers, embedded systems.
  • Databases, brokers, high-frequency trading.
  • Maintaining a large existing C++ codebase.

Avoid it when

  • Ordinary web apps and CRUD: the development cost and memory bug risk are not justified.
  • A new project where memory safety is critical and Rust is a fit.

Key concepts

RAII
A resource (memory, file, lock) is acquired in the constructor and released in the destructor.
Smart pointers
unique_ptr and shared_ptr manage object lifetime automatically.
Templates
Generic code that is instantiated at compile time for each type.
STL
The standard library: containers (vector, map), algorithms, iterators.
Undefined behavior
Bugs like out-of-bounds access do not necessarily crash, and program behavior may be arbitrary.

Example

unique_ptr and vector: memory is freed automatically.

Interview questions

  1. 1. What is RAII?

    The principle that a resource's lifetime is tied to an object's lifetime: the constructor acquires it, the destructor releases it. That prevents leaks even when exceptions occur.

  2. 2. How does unique_ptr differ from shared_ptr?

    unique_ptr has a single owner and is move-only. shared_ptr counts references and frees the object when none remain. The first is cheaper, so it is the default choice.

  3. 3. What is move semantics?

    The ability to transfer a temporary object's resources instead of copying them (rvalue references, std::move). It speeds up work with large containers and strings.

  4. 4. Why do you need a virtual destructor?

    If you delete a derived object through a base class pointer, the base destructor must be virtual, otherwise the derived destructor is not called, causing a leak or UB.

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).