History
- How:
- Developed by Bjarne Stroustrup in 1979 at Bell Labs.
- Originally called “C with Classes”, renamed to C++ in 1983.
- Evolved through major standards: C++98, C++03, C++11, C++14, C++17, C++20, C++23.
- Who:
- Bjarne Stroustrup — creator of C++, computer scientist at Bell Labs / AT&T.
- Why:
- To add object-oriented programming to C while keeping its raw performance.
- To support both low-level system programming and high-level application development.
- To introduce abstractions (classes, templates, RAII) without sacrificing speed.
-
Introduction
-
Advantages
- Performance & Control — Direct memory access via pointers, zero-cost abstractions, ideal for games, OS, embedded systems.
- Multi-Paradigm — Supports procedural, object-oriented, and generic programming (templates).
- STL — Rich standard library: vectors, maps, algorithms, iterators.
- RAII — Resource Acquisition Is Initialization ensures safe resource management.
- Compatibility with C — Can integrate legacy C code directly.
- Cross-Platform — Compiles on Linux, Windows, macOS, embedded targets.
-
Disadvantages
- Complex Syntax — Steeper learning curve than Python or Java.
- Manual Memory Management — Risk of memory leaks and segfaults without smart pointers.
- Long Compile Times — Heavy template usage can slow builds significantly.
- No Garbage Collection — Developer is responsible for memory lifecycle.
- Undefined Behavior — Many operations (out-of-bounds, null deref) are UB, not exceptions.
-
Basics
-
Hello World & Entry Point
main() is the program entry point, returns int (0 = success).
#include <iostream> brings in the standard I/O stream library.
-
-
Variables & Data Types
-
Primitive Data Types Table
-
Type Modifiers
-
auto & Type Deduction (C++11)
-
-
Operators
-
Type Casting
-
Control Flow
-
if / else if / else
collapsed:: true
-
Switch Statement
collapsed:: true
-
Ternary Operator
collapsed:: true
-
Loops
collapsed:: true
-
break / continue / goto
collapsed:: true
-
Functions
-
Declaration, Definition & Calling
collapsed:: true
-
Default Arguments
collapsed:: true
-
Function Overloading
collapsed:: true
-
Pass by Value, Reference & Pointer
collapsed:: true
-
Inline Functions
collapsed:: true
-
Recursive Functions
collapsed:: true
-
Lambda Functions (C++11)
collapsed:: true
-
std::function & Function Pointers
collapsed:: true
-
Pointers & References
-
Pointers Basics
collapsed:: true
-
Pointer Arithmetic
collapsed:: true
-
Null Pointer & nullptr (C++11)
collapsed:: true
-
References
collapsed:: true
-
const Pointers
collapsed:: true
-
Dynamic Memory (new / delete)
collapsed:: true
-
Arrays & Strings
-
C-Style Arrays
collapsed:: true
-
std::array (C++11) — Preferred over C arrays
collapsed:: true
-
std::string
collapsed:: true
-
String Views (C++17) — Zero-copy string reference
collapsed:: true
-
OOP — Object-Oriented Programming
-
Classes & Objects
collapsed:: true
-
Constructors & Destructors
collapsed:: true
-
Access Modifiers
collapsed:: true
-
Getters & Setters (Encapsulation)
collapsed:: true
-
Static Members
collapsed:: true
-
Friend Functions & Classes
collapsed:: true
-
Operator Overloading
collapsed:: true
-
OOP — Inheritance
-
Single Inheritance
collapsed:: true
-
Inheritance Types
collapsed:: true
-
Multi-Level & Multiple Inheritance
collapsed:: true
-
Virtual Inheritance (Diamond Problem Fix)
collapsed:: true
-
Constructor Chaining
collapsed:: true
-
OOP — Polymorphism
-
Virtual Functions & Runtime Polymorphism
collapsed:: true
-
Pure Virtual Functions & Abstract Classes
collapsed:: true
-
override & final (C++11)
collapsed:: true
-
vtable & vptr (How Virtual Works Internally)
collapsed:: true
- Each class with virtual functions has a vtable (virtual function table).
- Each object has a hidden vptr pointing to its class’s vtable.
- At runtime, the correct function is looked up via the vtable — this is dynamic dispatch.
-
OOP — Advanced Concepts
-
Rule of Three / Five / Zero
collapsed:: true
-
Move Semantics & rvalue References (C++11)
collapsed:: true
-
RAII (Resource Acquisition Is Initialization)
collapsed:: true
-
Smart Pointers (C++11)
-
unique_ptr — Exclusive Ownership
collapsed:: true
-
shared_ptr — Shared Ownership
collapsed:: true
-
weak_ptr — Non-Owning Observer
collapsed:: true
-
Smart Pointer Comparison
collapsed:: true
-
Templates & Generic Programming
-
Function Templates
collapsed:: true
-
Class Templates
collapsed:: true
-
Template Specialization
collapsed:: true
-
Variadic Templates (C++11)
collapsed:: true
-
Concepts (C++20) — Constrained Templates
collapsed:: true
-
STL — Standard Template Library
-
Containers Overview
collapsed:: true
-
vector
collapsed:: true
-
map & unordered_map
collapsed:: true
-
set & unordered_set
collapsed:: true
-
stack, queue, priority_queue
collapsed:: true
-
STL Algorithms
collapsed:: true
-
Iterators
collapsed:: true
-
Exception Handling
-
try / catch / throw
collapsed:: true
-
Standard Exception Hierarchy
collapsed:: true
-
Custom Exceptions
collapsed:: true
-
noexcept (C++11)
collapsed:: true
-
Modern C++ Features
-
C++11 Key Features
collapsed:: true
-
C++14 Key Features
collapsed:: true
-
C++17 Key Features
collapsed:: true
-
C++20 Key Features
collapsed:: true
-
C++23 Highlights
collapsed:: true
-
Concurrency & Multithreading
-
std::thread (C++11)
collapsed:: true
-
Mutex & Lock Guard
collapsed:: true
-
Condition Variables
collapsed:: true
-
std::async & std::future
collapsed:: true
-
Atomic Operations (C++11)
collapsed:: true
-
File I/O
-
Reading & Writing Files
collapsed:: true
-
Binary File I/O
collapsed:: true
-
String Streams
collapsed:: true
-
Namespaces
-
Defining & Using Namespaces
collapsed:: true
-
Anonymous Namespaces
collapsed:: true
-
Preprocessor & Compilation
-
Preprocessor Directives
collapsed:: true
-
Predefined Macros
collapsed:: true
-
collapsed:: true
-
Advanced Topics
-
Type Traits (C++11)
collapsed:: true
-
SFINAE & enable_if (Pre-C++20)
collapsed:: true
-
constexpr & Compile-Time Programming
collapsed:: true
-
Memory Model & Alignment
collapsed:: true
-
Design Patterns in C++
collapsed:: true
-
Structured Bindings (C++17)
collapsed:: true
-
Utilities & Practical STL
-
std::pair & std::tuple
collapsed:: true
-
std::deque, std::list, std::forward_list
collapsed:: true
-
std::initializer_list
collapsed:: true
-
std::chrono — Time & Duration
collapsed:: true
-
std::random — Random Number Generation
collapsed:: true
-
std::regex — Regular Expressions
collapsed:: true
-
collapsed:: true
-
Scope, Storage & Linkage
-
Variable Scope
collapsed:: true
-
Storage Duration
collapsed:: true
-
Linkage (extern, static)
collapsed:: true
-
Bit Manipulation
-
Bitwise Operations
collapsed:: true
-
Common Bit Tricks
collapsed:: true
-
std::bitset
collapsed:: true
-
-
g++ / clang++ Compilation
collapsed:: true
-
CMake Basics
collapsed:: true
-
Miscellaneous
-
Enums & Scoped Enums
collapsed:: true
-
Unions & std::variant
collapsed:: true
-
Escape Sequences
collapsed:: true
-
Useful Standard Headers
collapsed:: true
-
Literals, Type Aliases & Character Manipulation
-
Literals & Suffixes
collapsed:: true
-
Type Aliases
collapsed:: true
-
Character Manipulation (<cctype>)
collapsed:: true
-
Arguments to main & Getting Things Out of Functions
-
argc & argv
collapsed:: true
-
Multiple Return Strategies
collapsed:: true
-
Overflow, Underflow & Numeric Limits
-
Integer Overflow & Underflow
collapsed:: true
-
Floating Point Precision
collapsed:: true
-
Deep Dive: Classes & Constructors
-
Class Memory Layout & this Pointer
collapsed:: true
-
Constructor Details
collapsed:: true
-
Three-Way Comparison & Logical Operators
-
Three-Way Comparison <=> (C++20)
collapsed:: true
-
Short-Circuit Evaluation
collapsed:: true
-
Function-Like Entities
-
Functors (Function Objects)
collapsed:: true
-
std::bind (C++11)
collapsed:: true
-
std::invoke (C++17)
collapsed:: true
-
Ranges Library (C++20)
-
Views & Pipelines
collapsed:: true
-
Range Algorithms
collapsed:: true
-
Coroutines (C++20)
-
Coroutine Basics
collapsed:: true
- A coroutine is a function that can suspend and resume execution.
- Uses three keywords:
co_await, co_yield, co_return
- Requires a promise type and a coroutine handle — usually provided by a library.
-
co_await — Async Suspension
collapsed:: true
-
Modules (C++20)
-
Module Basics
collapsed:: true
- Modules replace
#include — faster compilation, no header guards, no macro leakage.
-
Module Partitions & std import
collapsed:: true
-
Building Custom Iterators
-
Iterator Concepts
collapsed:: true
-
Custom Iterator Implementation
collapsed:: true
-
Library & Frameworks
- STL (Standard Template Library) - Vectors, maps, sets, algorithms, iterators — the backbone of every C++ program.
- Boost - Peer-reviewed libraries extending C++: threading, filesystem, smart pointers, regex, and more.
- Qt - Cross-platform GUI framework with networking, database, and mobile support.
- OpenCV - Computer vision library for real-time image processing and object detection.
- SFML (Simple and Fast Multimedia Library) - Graphics, sound, and input for game development.
- Eigen - Template library for linear algebra, matrices, and vectors — used in ML and scientific computing.
- C++ REST SDK (cpprest) - Cross-platform RESTful web services and HTTP communication.
- POCO (C++ Portable Components) - HTTP, database, JSON/XML parsing for networked applications.
- Google Test (gtest) - Unit testing framework with mock objects and assertions.
- ACE (Adaptive Communicative Environment) - High-performance networked and real-time systems.
- TBB (Threading Building Blocks) - Intel’s parallel programming library for multi-core performance.
- SDL (Simple DirectMedia Layer) - Cross-platform multimedia: audio, graphics, input for games.
- std::format - Fast, safe string formatting (basis for C++20
<format>).
- Catch2 - Modern, header-only C++ testing framework — simpler than gtest.
- json - Single-header JSON library, the most popular C++ JSON parser.
- spdlog - Fast, header-only logging library for C++.
-
More Learn