C++ Programming
C++ is a systems programming language that extends C with object-oriented features, templates, and a standard library. It provides fine-grained control over memory and hardware while supporting abstractions that scale to large codebases, used in games, databases, browsers, and embedded systems.
itProgramming languages | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic — C++ Programming
C++ is a general-purpose programming language that lets a program work close to hardware while still building reusable interfaces with classes, templates, and the standard library. That combination is useful when representation, native performance, and deterministic resource cleanup matter. It is also why C++ has enough vocabulary to fill a small cupboard and enough sharp edges to make the cupboard feel personal.
The useful mental model starts with three layers. The language defines types, expressions, classes, templates, and behavior. An implementation supplies a compiler, library implementation, and target environment. The standard library supplies the everyday tools: strings, containers, algorithms, input and output, and concurrency facilities. A compiler extension is not automatically part of the language, however confidently it compiles.
Then follow the build path. Source files and headers become translation units after preprocessing. The compiler turns those into object files. The linker combines object files and libraries into a program. Choose a language version explicitly, because the standard does not prescribe one command or build system. CMake gives a target a home for that requirement, which is less exciting than a surprise build failure and therefore preferable.
The part that earns the caution labels is lifetime. An object occupies storage for a period of execution. A pointer or reference can remain after that period ends, which leaves an access dangling. Types can be perfectly correct while the program is still wrong. The same applies when a container operation invalidates an iterator, pointer, or reference that looked trustworthy five lines earlier.
RAII is the main structural answer. Put a resource in an object and its destructor releases the resource when the object's lifetime ends. A string owns its characters. A vector owns its sequence. A unique pointer makes exclusive dynamic ownership explicit. This protects cleanup across ordinary returns and exceptions without scattering cleanup duties through every exit path.
Start with values, strings, vectors, functions, and algorithms. Then add classes, invariants, lifetime, ownership, and RAII. Templates and concepts come after the concrete shape of the work is clear. The Cheatsheet holds the compact vocabulary. The slides connect the pieces. The practice reference turns the build, warning, and sanitizer loop into commands. The exercise asks for a small program whose ownership and lifetime answers survive contact with a compiler.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://www.iso.org/standard/83626.html
Supports
- ISO/IEC 14882:2024 is edition 7 of the published C++ programming language standard
- The standard was published in October 2024 and is the edition commonly associated with C++23
- C++ is a general-purpose language with classes, templates, exceptions, namespaces, overloading, references, free-store operators, and standard-library facilities
- The standard defines C++ and requirements for C++ implementations
- https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf
Supports
- N4950 is the final public working draft that formed the basis of the C++23 international standard
- C++ defines translation units, declarations, definitions, objects, references, types, expressions, statements, functions, classes, templates, and exceptions
- A hosted program contains a global function named main and execution invokes it
- Object and reference lifetimes bound when stored values and referred-to objects may be used
- Undefined behavior places no requirements on an implementation
- The standard library specifies strings, containers, iterators, algorithms, smart pointers, input and output, concurrency, and other facilities
- unique_ptr models unique ownership and shared_ptr uses shared ownership semantics
- Concepts and constraints state requirements for template arguments
- Stack unwinding destroys constructed automatic objects when an exception propagates
- https://www.open-std.org/jtc1/sc22/wg21/docs/standards
Supports
- WG21 publishes public drafts corresponding to C++ standard editions
- N4950 is listed as the draft for the 2023 edition
- WG21 is the ISO working group for C++ standardization
- https://isocpp.org/get-started
Supports
- The Standard C++ Foundation lists compiler options for major operating systems
- The page curates modern C++ learning material and standard-library references
- Compiler installation is the first practical step in its learning path
- https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
Supports
- The C++ Core Guidelines focus on interfaces, resource management, memory management, concurrency, and related high-level concerns
- RAII binds resource lifetime to object lifetime and supports cleanup across error paths
- Prefer scoped objects and resource handles over explicit allocation and deallocation
- Use unique_ptr or shared_ptr to represent ownership when dynamic ownership is required
- Prefer unique_ptr over shared_ptr unless ownership must be shared
- Aim for the rule of zero by composing resource-managing members
- Prefer a standard-library container to a C-style array for ordinary application code
- https://en.cppreference.com/w/cpp/language
Supports
- The C++ language reference organizes object, scope, lifetime, definitions, translation, expressions, classes, templates, exceptions, and undefined behavior
- C++20 introduced modules and concepts
- References, pointers, classes, and templates are distinct language facilities
- https://en.cppreference.com/w/cpp/language/raii
Supports
- RAII binds a resource lifecycle to an object lifetime
- Destruction in reverse acquisition order supports resource release on normal and exceptional exits
- Standard-library strings, vectors, smart pointers, and lock wrappers apply RAII
- Move semantics can transfer ownership while preserving resource safety
- https://en.cppreference.com/w/cpp/language/lifetime
Supports
- Every object and reference has a runtime lifetime
- A reference may remain accessible after the referred object's lifetime and become dangling
- Several forms of access outside an object's lifetime have undefined behavior
- https://en.cppreference.com/w/cpp/container
Supports
- Standard containers organize sequence, ordered associative, and unordered associative data structures
- Containers manage storage for their elements and expose iterator-based access
- Container choice depends on supported operations and workload efficiency
- Iterator invalidation and thread-safety rules depend on operations and container types
- https://en.cppreference.com/w/cpp/container/vector
Supports
- vector is a resizable contiguous sequence container
- vector manages element storage automatically
- Reallocation invalidates all element references, pointers, and iterators
- Unchecked element access does not provide automatic bounds checking
- https://en.cppreference.com/w/cpp/ranges
Supports
- The C++20 ranges library generalizes iterator and algorithm interfaces
- Range views are lightweight representations of iterable sequences
- Range adaptors can compose lazy view pipelines
- https://clang.llvm.org/docs/AddressSanitizer.html
Supports
- AddressSanitizer combines compiler instrumentation with a runtime library
- It detects out-of-bounds access, use after free, invalid free, double free, and other memory errors during execution
- Clang enables AddressSanitizer with the address sanitizer compiler option
- AddressSanitizer does not replace broader design review or prove arbitrary program correctness
- https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
Supports
- UndefinedBehaviorSanitizer adds compile-time instrumentation for selected invalid operations
- Checks include out-of-bounds indexing, misaligned or null pointer use, invalid shifts, and signed integer overflow
- Clang enables the undefined-behavior check group with the undefined sanitizer option
- https://cmake.org/cmake/help/latest/guide/tutorial/index.html
Supports
- The official CMake tutorial is a step-by-step guide to common build-system tasks
- CMake projects declare languages, targets, sources, and compile-feature requirements
- Target-level requirements avoid dependence on implicit local compiler defaults
- https://stroustrup.com/hopl2.pdf
Supports
- C++ began as C with Classes between 1979 and 1983
- The language evolved into C++ between 1982 and 1985 and reached its first commercial release in 1985
- https://isocpp.org/std/the-standard
Supports
- The Standard C++ Foundation identifies C++23 as ISO/IEC 14882:2024(E)
- C++23 completed technical work in 2023 and was published administratively as the 2024 ISO edition
- https://cmake.org/licensing/
Supports
- CMake is distributed under a permissive open-source license
- https://conan.io/
Supports
- Conan is an MIT-licensed package manager for C and C++ that integrates with native build toolchains
- https://github.com/microsoft/vcpkg/blob/master/LICENSE.txt
Supports
- vcpkg is distributed under the MIT License
- https://www.qt.io/development/qt-framework/qt-licensing
Supports
- Qt offers commercial licensing alongside GPL and LGPL open-source licensing options
- https://www.jetbrains.com/clion/buy/
Supports
- CLion offers free non-commercial use and paid commercial subscriptions
