Skip to content

C++ Introduction: What It Is and Why Learn It

C++ (pronounced "C plus plus") is a fast, compiled, general-purpose programming language. It gives you two things that rarely come together: high-level features such as classes, templates and a rich standard library, and low-level control over memory and hardware. That combination is why C++ runs inside web browsers, game engines, databases, operating systems, trading platforms and the firmware of everyday devices.

This is the first lesson of the MakeMyCodes C++ tutorial. It explains what C++ is, where it came from, why it is still one of the most important languages, and what happens when you turn C++ source code into a running program. The next lessons cover installing a compiler, syntax, variables and data types, with every program actually compiled and run.

Think of programming languages as vehicles. Python is an automatic car: easy to drive, and it takes care of most things for you. C++ is a manual sports car: you control the gears yourself, which takes practice, but you get the maximum performance out of the engine.

What is C++?

In one sentence: C++ is a statically typed, compiled language that supports procedural, object-oriented and generic programming, and gives the programmer direct control over memory. Let's break that down:

TermWhat it means in practice
CompiledA compiler translates your source code into machine code for the processor before it runs. The result is an executable file (.exe on Windows) that runs without any interpreter or virtual machine.
Statically typedEvery variable has a type (int, double, std::string...) that is checked when you compile. Many mistakes are caught before the program ever runs.
Multi-paradigmYou can write plain functions (procedural, like C), classes and objects (object-oriented), or type-independent code with templates (generic programming).
Close to the hardwareYou can work with memory addresses (pointers), decide where objects live, and control exactly when memory is allocated and released.
Zero-overhead abstractionsA key design rule: features you don't use cost nothing, and features you do use should be as fast as code you'd write by hand.

A short history of C++

C++ was created by Bjarne Stroustrup at Bell Labs, starting in 1979. He wanted the speed and hardware access of the C language together with the classes of Simula, a language that made large programs easier to organise. His first version was literally called "C with Classes". In 1983 it was renamed C++: in C, ++ is the increment operator, so the name means "one step beyond C".

Since 1998 C++ has been an ISO international standard, and a new version now appears every three years:

StandardHighlights
C++98 / C++03First official standard: classes, templates, exceptions, the Standard Template Library (STL)
C++11"Modern C++" begins: auto, lambdas, smart pointers, range-based for, move semantics, brace initialisation
C++14Smaller improvements: binary literals, digit separators (1'000'000)
C++17std::optional, std::string_view, structured bindings, the filesystem library
C++20Concepts, ranges, modules, coroutines, std::format
C++23std::print, std::expected, more ranges

The compiler tells you which standard it is using through the predefined value __cplusplus. We compiled one tiny program with GCC's g++ 14.2 under different -std options:

Output
-std=c++11  __cplusplus = 201103
-std=c++14  __cplusplus = 201402
-std=c++17  __cplusplus = 201703
-std=c++20  __cplusplus = 202002
-std=c++23  __cplusplus = 202302

Without any option, g++ 14 used 201703, that is, C++17. In this tutorial we compile with -std=c++20.

Why learn C++ today?

  • Performance: C++ compiles to native machine code with no garbage collector pausing your program. When every millisecond or every megabyte matters, C++ is usually the first choice.
  • Control: you decide how memory is used. That's essential for games, embedded devices with a few kilobytes of RAM, and real-time systems.
  • It's everywhere: much of the software you use daily is written in C++, so the jobs and the existing code bases are huge.
  • It teaches you how computers work: memory, the stack and heap, pointers, compilation and linking. That knowledge makes you better in every other language, including C#, Java and Python.
  • Strong in interviews and competitive programming: the STL (vectors, maps, algorithms) and C++'s speed make it the most popular language on competitive-programming platforms.

Where C++ is used

AreaExamples
Game developmentUnreal Engine is written in C++, and so is most AAA game code
Web browsersChrome, Firefox and Edge use C++ for their rendering and JavaScript engines
Operating systems and driversLarge parts of Windows, macOS components, device drivers
DatabasesMySQL, MongoDB and many other database engines
FinanceHigh-frequency trading systems, where microseconds matter
Embedded and IoTCars, medical devices, routers and smart devices
Machine learningThe fast core of TensorFlow and PyTorch is C++; Python is the friendly layer on top
Desktop applicationsAdobe tools, Microsoft Office components, and Qt-based applications

Key features of C++

  • Object-oriented programming: classes, objects, encapsulation, inheritance and polymorphism (covered later in this course).
  • Templates: write one function or class that works with many types; the STL is built on them.
  • Standard Library: ready-made strings, dynamic arrays (std::vector), maps, algorithms, input/output, threads and more.
  • Manual and automatic memory management: you can allocate memory yourself, but modern C++ prefers RAII and smart pointers, which release resources automatically.
  • Compatibility with C: most C code can be used directly from C++, giving access to decades of libraries.
  • Portability: standard C++ code compiles on Windows, Linux, macOS and embedded platforms. The source is portable; the compiled executable is built separately for each platform.
  • Case sensitive: total, Total and TOTAL are three different names.

How a C++ program becomes a running program

This is the most important difference from languages like Python. A C++ source file goes through four stages before it can run:

hello.cpp  --(1) preprocessor-->  expanded source  --(2) compiler-->  assembly
          --(3) assembler-->  hello.o (object file)  --(4) linker-->  hello / hello.exe
  1. Preprocessing: lines starting with # are handled first. #include <iostream> literally pastes the contents of the iostream header into your file. Our 7-line hello-world program grew to 33,392 lines after preprocessing (g++ -E hello.cpp).
  2. Compilation: the compiler checks syntax and types, optimises, and translates C++ into assembly code for your processor.
  3. Assembly: the assembler turns that into machine code in an object file (.o or .obj). Ours was 2,272 bytes.
  4. Linking: the linker combines your object files with the libraries you use (here, the C++ standard library) and produces the final executable. Ours was 18,832 bytes.

Usually one command does all four steps: g++ hello.cpp -o hello. Knowing the stages helps you understand error messages: a compiler error means your code is wrong (a missing semicolon, an unknown name), while a linker error ("undefined reference") means something was declared but its implementation couldn't be found.

Here is the classic first program and its real output. The syntax lesson explains every line.

#include <iostream>

int main()
{
    std::cout << "Hello, World!" << std::endl;
    std::cout << "Welcome to C++ at MakeMyCodes" << std::endl;
    return 0;
}
Output
Hello, World!
Welcome to C++ at MakeMyCodes

C vs C++ vs Java vs C#

AspectCC++Java / C#
ParadigmProceduralProcedural, object-oriented, genericMainly object-oriented
Runs asNative machine codeNative machine codeBytecode / IL on a virtual machine (JVM / .NET CLR), compiled just in time
MemoryManual (malloc/free)Manual or automatic with RAII and smart pointersGarbage collector
ClassesNo (only struct without methods)YesYes
Multiple inheritance of classesNot applicableYesNo (interfaces only)
PointersYesYes, plus referencesNo raw pointers in normal code (C# allows them in unsafe code)
Standard librarySmallLarge (STL)Very large frameworks

If you already know C#, much of the syntax will look familiar, because C# borrowed it from C and C++. The big new ideas will be header files, pointers, manual memory control and the compile-and-link model.

Advantages and disadvantages

AdvantagesDisadvantages
Very fast, predictable performanceSteeper learning curve than Python, C# or Java
Full control over memory and hardwareMemory mistakes (leaks, dangling pointers) are possible
Huge ecosystem of libraries and toolsLong compile times on large projects
Portable source code across platforms"Undefined behaviour": some bugs give no error, just wrong results
Backed by an ISO standard and many compilersLarge language with many ways to do the same thing

Interview questions

Who developed C++ and why is it called C++?

Bjarne Stroustrup at Bell Labs, starting in 1979, as "C with Classes". It was renamed C++ in 1983; ++ is C's increment operator, meaning an improved C.

Is C++ a purely object-oriented language?

No. C++ supports object-oriented programming, but you can also write procedural code with free functions and global variables, and generic code with templates. Every program starts in the free function main(), not inside a class.

Is C++ compiled or interpreted?

Compiled. The compiler and linker produce a native executable for a specific platform, which runs directly on the processor without an interpreter or virtual machine.

More questions are on the C++ basics interview questions page.

Summary

  • C++ is a compiled, statically typed, multi-paradigm language created by Bjarne Stroustrup as an extension of C.
  • It combines high-level features (classes, templates, the STL) with low-level control over memory.
  • It's used where performance matters: games, browsers, databases, finance, embedded systems and the core of ML libraries.
  • Source code goes through preprocessing, compilation, assembly and linking to become an executable.
  • A new ISO standard appears every three years; "modern C++" means C++11 and later.

Next lesson: Install a C++ compiler on Windows and run your first program.