C++ Tutorial · C++ Basics · Lesson 1 of 21

C++ Introduction

What C++ is, where it's used and a first program.

What is C++?

C++ is a fast, compiled, statically typed language created by Bjarne Stroustrup as an extension of C. It gives you direct control over memory and hardware along with high-level abstractions — classes, templates and a rich standard library.

C++ is used where performance matters: game engines (Unreal), browsers (Chrome), databases, trading systems, embedded devices, compilers and machine-learning runtimes.

Hello, World!

Hello, World!
#include <iostream>

int main() {
    std::cout << "Hello, World!\n";
}

Output

Hello, World!

Run this on your computer — see “Get Started” for setup.

  • #include <iostream> brings in input/output streams.
  • int main() is where the program starts.
  • std::cout << ... writes to the console; '\n' ends the line.

This tutorial teaches modern C++ (C++20). Examples show the program and its output — compile them yourself with g++ -std=c++20 main.cpp.

Test yourself

Which object writes to the console in C++?

  1. printf
  2. std::cout
  3. console.log
  4. System.out
Show answer

Answer: std::cout