AheadKit

Free chapter — read online

C++ for Everyone: Chapter 1, free to read

This is a free chapter of C++ for Everyone: Chapter 1 — “Introduction” — all 4 pages (pages 5–8 of the full 439-page book), exactly as they appear in the book. No edits, no teaser cuts.

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;
}

That was Chapter 1. The book has 30 more chapters.

The full book: 439 pages, 31 chapters and 13 step-by-step projects, for $3.99 — or all 11 programming books in the bundle for $12.99.

Added to cart