Skip to content

Introduction

Welcome to the world of C++! This chapter will introduce you to the C++ programming language, its rich history, and why it remains one of the most important and widely-used programming languages today. Whether you’re completely new to programming or coming from another language, this chapter will give you the foundation you need to become proficient in C++.

C++ is a high-performance, general-purpose programming language that was developed as an extension of the C programming language. It adds object-oriented, generic, and functional programming features while maintaining the low-level memory manipulation capabilities that make C so powerful.

C++ is known for its:

  • Performance: Near-direct access to hardware resources with minimal runtime overhead
  • Flexibility: Supports multiple programming paradigms (procedural, object-oriented, generic, functional)
  • Standard Library: The Standard Template Library (STL) provides ready-to-use data structures and algorithms
  • Portability: Standardized by ISO, code can be compiled on virtually any platform

Understanding the history of C++ helps you understand why the language has the features it does today.

C++ was created by Bjarne Stroustrup at Bell Labs, starting as “C with Classes.” Stroustrup wanted to add object-oriented features to C while maintaining compatibility and performance. The first commercial release was in 1985.

YearStandardMajor Features
1985C++ 1.0Classes, inheritance, encapsulation
1990C++ 2.0Multiple inheritance, abstract classes
1998C++98First ISO standard, STL
2003C++03Bug fixes and clarifications
2011C++11Smart pointers, lambdas, move semantics, threads
2014C++14Generic lambdas, return type deduction
2017C++17if constexpr, structured bindings, parallel algorithms
2020C++20Concepts, ranges, modules, coroutines
2023C++23std::print, std::expected, deducing this

C++ evolves continuously to address modern programming challenges. Each standard adds features while maintaining backward compatibility. Modern C++ (C++11 and later) is dramatically different from earlier versions, offering safer and more expressive syntax.

Here are compelling reasons to learn C++:

C++ gives you near-metal control over system resources. You decide exactly how memory is allocated, when functions are called, and how data is laid out in memory. This makes C++ ideal for:

  • Operating Systems: Windows, Linux, macOS all have significant C++ components
  • Game Development: Unreal Engine, Unity (core), most game engines
  • Embedded Systems: Microcontrollers, IoT devices
  • High-Frequency Trading: Where every microsecond counts
  • Graphics and Vision: OpenCV, computer graphics engines

C++ developers are in high demand:

  • Systems Programming: Operating systems, drivers, firmware
  • Game Development: One of the highest-paying programming fields
  • Finance: Quantitative trading, risk analysis
  • Software Infrastructure: Databases, compilers, browsers
  • Automotive and Aerospace: Safety-critical systems

Understanding C++ helps you understand how computers actually work:

  • Memory Management: Learn how memory is allocated and deallocated
  • Pointers: Understand how data is accessed at the hardware level
  • Performance Tuning: Learn to write efficient code
  • System Design: Understand trade-offs in software architecture

Many modern languages are influenced by C++ or built on top of it:

  • C#: Microsoft’s .NET language
  • Java: Influenced by C++ syntax
  • Rust: Modern systems language (different paradigm)
  • Python: Many core libraries are in C++

C++ powers many of the applications and systems you use daily:

  • Windows (Microsoft Windows is primarily written in C and C++)
  • Linux kernel (C)
  • macOS and iOS (Objective-C and C++)
  • Android (C++ for performance-critical components)
  • Google Chrome (C++)
  • Mozilla Firefox (C++)
  • Microsoft Edge (C++)
  • MySQL
  • PostgreSQL
  • MongoDB
  • Redis
  • Unreal Engine
  • Unity (core components)
  • Unity uses C# but the engine itself is C++
  • Adobe Photoshop
  • Microsoft Office
  • AutoCAD
  • NASA rovers
  • Stock trading systems

Let’s look at your first C++ program:

#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}

Let’s break down each part:

#include <iostream>

This is a preprocessor directive that includes the input/output stream library. This gives us access to std::cout for printing to the console.

int main() {

Every C++ program needs a main() function. It’s the entry point where program execution begins. The int return type indicates the program’s exit status (0 means success).

std::cout << "Hello, World!" << std::endl;

std::cout is the standard output stream (console). The << operator sends the string “Hello, World!” to the output, followed by std::endl which adds a newline.

return 0;

Returning 0 from main() indicates successful program completion. Non-zero values indicate errors.

To compile this program, you’ll need a C++ compiler. Here’s how to compile on different systems:

Linux/macOS:

Terminal window
g++ -o hello hello.cpp
./hello

Windows (with MinGW or Visual Studio):

Terminal window
g++ -o hello.exe hello.cpp
hello.exe

Or in Visual Studio:

cl /EHsc hello.cpp
hello.exe

Before you can write C++ programs, you need to set up your development environment. Chapter 02 covers this in detail, but here’s a quick overview:

If you want to start immediately without installing anything:

  • Compiler Explorer (godbolt.org): Interactive compiler with assembly output
  • Replit: Cloud-based IDE with C++ support
  • OnlineGDB: Web-based compiler and debugger
  • Windows: Visual Studio (Community edition is free) or MinGW-w64
  • macOS: Xcode Command Line Tools or Homebrew’s gcc
  • Linux: GCC or Clang (usually pre-installed)

We’ll cover installation in detail in the next chapter.

This guide is organized into logical sections that build upon each other:

  1. Fundamentals: Basic syntax, variables, data types, control flow
  2. Object-Oriented Programming: Classes, inheritance, polymorphism
  3. Standard Template Library (STL): Containers, algorithms, iterators
  4. Memory Management: Pointers, smart pointers, memory best practices
  5. Modern C++: C++11/14/17/20 features
  6. Templates and Generics: Generic programming
  7. Concurrency: Multithreading and synchronization
  8. Best Practices: Design patterns, code organization
  9. Performance: Optimization techniques
  10. Build Systems: CMake, makefiles
  11. Testing: Unit testing, debugging
  • C++ is a powerful, high-performance language that gives you close-to-the-metal control
  • It was created as an extension of C by Bjarne Stroustrup in 1979
  • Modern C++ (C++11 and later) is dramatically safer and more expressive than earlier versions
  • C++ is used in operating systems, games, databases, browsers, and many other performance-critical applications
  • Every C++ program must have a main() function as its entry point

Now that you understand what C++ is and why it’s important, let’s set up your development environment in the next chapter.

Next Chapter: 02_environment_setup.md - Setting up your development environment