C++ - Introduction
Overview
Estimated time: 20–30 minutes
C++ is a powerful systems programming language used for high-performance applications, games, embedded systems, and more. This introduction orients you to modern C++ (C++17/20/23), the standard library, and what you’ll learn next.
Learning Objectives
- Describe what C++ is good at and where it’s commonly used.
- Understand modern C++ standards and the role of the standard library (STL).
- Know the immediate next steps: installing a toolchain and writing your first program.
Prerequisites
- None. This is the first lesson.
Why C++?
- Performance and control: value semantics, RAII, deterministic destructors.
- Vast ecosystem: STL, Boost, and third-party libraries for practically any domain.
- Portability across platforms and compilers.
Example
#include <iostream>
int main(){
std::cout << "Hello, C++!\n";
return 0;
}
Expected Output:
Hello, C++!
Common Pitfalls
- Confusing old C++ (pre-11) with modern C++. We target C++20 features where helpful, and show pre-C++20 alternatives.
- Skipping RAII: always prefer automatic resource management (smart pointers, containers) over manual new/delete.
Checks for Understanding
- What are typical use cases for C++?
- What is the STL?
Show answers
- High-performance apps, games, embedded, real-time systems, finance, and more.
- The Standard Template Library: containers, algorithms, iterators, and utilities shipped with C++.
Exercises
- Compile and run the sample program using your compiler (clang++, g++, or MSVC).
- Modify the program to print your name and a goal you have for learning C++.