30 Mins

1. Introduction to C++

Introduction

C++ is a powerful, high-performance programming language that gives you fine control over system resources and memory. It was developed by Bjarne Stroustrup as an extension of the C language, adding object-oriented features while retaining C's performance.

Today, C++ is used everywhere — from operating systems and game engines to high-frequency trading platforms and embedded systems. Learning C++ teaches you how computers really work under the hood.

This course will take you from absolute beginner to confident C++ developer, covering every concept with practical, runnable code examples.

What Can C++ Do?

C++ is a systems programming language that powers critical infrastructure across every domain in technology:

  • Game Development — Unreal Engine and many AAA games are built with C++
  • Operating Systems — Windows, macOS, Linux kernels have C++ components
  • Embedded Systems — Microcontrollers, medical devices, automotive software
  • High-Frequency Trading — Milliseconds matter, and C++ delivers speed
  • Graphics and VR — Real-time 3D rendering demands C++ performance

Your First C++ Program

The tradition in programming is to start by printing Hello, World! to the screen. In C++, this requires including the iostream library and writing a main function.

C++
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
OutputHello, World!

The #include directive tells the compiler to include the iostream library, which provides input/output functionality. The std::cout object sends output to the console, and std::endl adds a new line. The main() function is where every C++ program starts executing, and return 0; indicates successful completion.

C++ Syntax vs Other Languages

C++ has a syntax that is similar to C and Java, using curly braces to define code blocks and semicolons to terminate statements. Unlike Python, C++ uses explicit type declarations and requires compilation before execution.

C++
#include <iostream>

int main() {
    // This is a C++ comment — the compiler ignores this line
    std::cout << "C++ uses semicolons and curly braces." << std::endl;
    std::cout << "Every statement ends with a semicolon." << std::endl;
    return 0;
}
OutputC++ uses semicolons and curly braces. Every statement ends with a semicolon.

The // symbol marks a single-line comment. Comments are notes for humans reading the code — the compiler completely ignores them. C++ also supports multi-line comments with /* */.

C++ Versions and Standards

C++ has evolved through several standards, each adding new features and improvements. The major standards are C++98, C++11 (which was a major leap), C++14, C++17, C++20, and the latest C++23.

  • Modern C++ (C++11 and later) introduced features that make the language safer and more expressive
  • Always use the latest standard your compiler supports (C++17 or C++20 is recommended)
  • You can specify the standard with compiler flags like -std=c++17
Quick Check: To check your compiler version, run g++ --version or clang++ --version in your terminal. Look for C++11, C++14, C++17, or C++20 support.

Compiling and Running C++ Code

Unlike Python which is interpreted, C++ is a compiled language. You write source code in a .cpp file, compile it with a compiler like g++ or clang++, and then run the resulting executable file.

C++
#include <iostream>

int main() {
    std::cout << "Compile with: g++ -o hello hello.cpp" << std::endl;
    std::cout << "Run with: ./hello" << std::endl;
    return 0;
}
OutputCompile with: g++ -o hello hello.cpp Run with: ./hello

Understanding the compile-run cycle is fundamental to working with C++. The compiler translates your human-readable code into machine code that your computer's processor can execute directly.

Knowledge Check

Ready to test your understanding of 1. Introduction to C++?

Back