Chapter 1: Introduction
Version: C++17/20
What is C++?
In 1979, a Danish computer scientist named Bjarne Stroustrup ran into a problem. C was fast, but it got messy in large projects. So he added classes to C and created "C with Classes" — which later became C++.
45 years later, C++ still runs the world:
- Games: Unreal Engine, almost every big game
- Systems: Windows, Chrome, databases (MySQL)
- Finance: Bank trading systems — crores of taka moving in milliseconds!
- Embedded: Cars, rockets (SpaceX!), robots
Why Learn C++?
- Speed. Python is easy but slow. C++ runs close to raw machine speed — 10 to 100 times faster! In games and
trading, you cannot do the job without that speed.
- The foundation of everything. Learn C++ and other languages get easier, because you will understand
memory — the thing Python hides from you. C++ is also the king of competitive programming.
- Jobs. Game development, systems programming, HFT (high-frequency trading) — these areas cannot
move without C++. The pay matches that.
How C++ Differs from Python
# Python
print("Hello")
// C++
#include <iostream>
int main() {
std::cout << "Hello";
return 0;
} Yes, you write more in C++. In return, you get control — you decide what happens to every byte in the computer!
Setup
Windows: Install MinGW-w64 or Visual Studio (Community, free). Mac/Linux: Type g++ --version in the terminal — in most cases it is already there.
VS Code + the C/C++ extension — that is it, you are ready!
Check it:
g++ --version
# g++ (GCC) 13.x or similar Your First Program
Create a file called hello.cpp :
#include <iostream>
int main() {
std::cout << "I am learning C++!";
return 0;
} Run it:
g++ hello.cpp -o hello
./hello Output:
I am learning C++! Let's Understand Each Line
Line Meaning
#include <iostream> Bring in the toolbox — tools for input/output
int main() { The start of the program — every C++ program starts from main
std::cout << "..." Show text on the screen
return 0; "Everything finished fine" — a message to the operating system
} The end
What is compiling? Python runs line by line (an interpreter). C++ first translates the whole code into machine language (compiling), then runs it. That is why C++ is so fast!
GOTCHA Every line must end with ; (semicolon) — miss it and you get a compile error! C++ just does not work without it.
Try It Yourself
- Print your name.
Answer
#include <iostream>
int main() {
std::cout << "My name is Salam";
return 0;
} - Print two sentences on two lines (hint: \n = new line).
Answer
#include <iostream>
int main() {
std::cout << "I am\n";
std::cout << "learning C++";
return 0;
}