Introduction to C++

C++ is an extension of the C language created by Bjarne Stroustrup in 1979. It adds Object-Oriented Programming (OOP), templates, exceptions, and the Standard Template Library (STL) while preserving direct hardware performance.

Why Learn C++?

Game Engines & Graphics

Unreal Engine, AAA games, DirectX, and OpenGL are built in C++ for maximum frame rate and millisecond-level responsiveness.

Standard Template Library (STL)

Instant access to highly optimized algorithms (sorting, searching) and data structures (vectors, hash maps, queues, heaps).

Modern Resource Management

RAII (Resource Acquisition Is Initialization) and Smart Pointers prevent memory leaks automatically without garbage collection.

First Modern C++ Program

C++ uses streams (std::cout and std::cin) via the <iostream> header.

Standard C++ (main.cpp):
main.cpp
1#include <iostream> 2#include <string> 3 4int main() { 5 std::string name; 6 std::cout << "Enter your name: "; 7 std::cin >> name; 8 9 std::cout << "Hello, " << name << "! Welcome to Modern C++.\n"; 10 return 0; 11}

Compilation Command

G++ compiler:
terminal
1# Compile with C++20 standard and optimizations 2g++ -std=c++20 -O2 main.cpp -o app 3 4# Run binary 5./app