Module 1 · Getting Started with C++ — topic 1 of 3
Introduction to C++
C++ is a compiled, multi-paradigm language that adds classes, templates, exceptions and a rich standard library to C while keeping C's performance and control over memory.
Learning objectives
- Describe where C++ came from and how it extends C
- Name the paradigms C++ supports
- Compile and run a first C++ program
Definition
C++ is a statically typed, compiled, general-purpose programming language standardised by ISO (C++98, 11, 14, 17, 20, 23) that supports procedural, object-oriented and generic programming with zero-overhead abstractions.
Introduction
Bjarne Stroustrup began C++ in 1979 as “C with Classes” at Bell Labs. He wanted the efficiency of C together with the program-organisation ideas of Simula, one of the first object-oriented languages. The language was renamed C++ in 1983 — ++ being C's increment operator.
Today C++ powers game engines (Unreal), browsers (Chrome's rendering engine), databases (MySQL, MongoDB), trading systems, compilers (LLVM) and much of the software inside cars and aircraft.
Why it matters
C++ lets you write high-level, reusable code — classes, templates, containers — without paying a run-time cost for features you don't use. That combination is why performance-critical industries still choose it.
Learning C++ also teaches object-oriented design and generic programming, ideas that transfer directly to Java, C# and Python, and it is the most popular language for competitive programming thanks to its fast Standard Template Library (STL).
Detailed explanation
C++ is compiled like C: g++ or clang++ translates .cpp files to native machine code. Almost every valid C program is also valid C++, but C++ is a separate language with stricter type rules.
C++ supports several paradigms: procedural (functions), object-oriented (classes, inheritance, virtual functions), generic (templates) and, since C++11, a functional style (lambdas).
The zero-overhead principle: what you don't use, you don't pay for; and what you do use, you couldn't hand-code any better. A std::vector is as fast as a carefully managed C array, but safer.
Syntax
<iostream>provides the standard input/output streams.std::coutis the standard output stream;<<inserts values into it.std::is the namespace of the standard library.- In C++,
int main()with empty parentheses means no parameters.
Code examples
Hello, C++
Hello, C++!
Chaining output
C++ got its name in 1983.
Each << sends one value to the stream; types are handled automatically, with no format specifiers.
More examples
A taste of the standard library
C C++ Java Python 4 languages
Step-by-step explanation
std::vector<std::string>is a growable array of strings that manages its own memory.std::sortsorts any range given by two iterators; strings compare alphabetically.- The range-based
forvisits each element;const std::string&avoids copying it. langs.size()returns the number of elements — no manual counting as in C.
Expected output
Running “A taste of the standard library” prints exactly:
Practical applications
- Game engines such as Unreal Engine are written in C++.
- Google Chrome, Firefox and most of Windows and macOS applications use C++.
- High-frequency trading systems use C++ for microsecond latency.
- Competitive programmers favour C++ for its fast STL.
Best practices
- Compile with
-std=c++17 -Wall -Wextra(or newer). - Prefer standard library types (
std::string,std::vector) over raw C arrays and char buffers. - Write
'\n'rather thanstd::endlunless you need to flush the stream.
Common mistakes
Forgetting the std:: prefix
Avoid
Prefer
Standard library names live in namespace std. Without the prefix (or a using-declaration) the name is not found.
Using C headers for C++ features
Avoid
Prefer
std::cout is declared in <iostream>, not <stdio.h>.
Important notes
- This course targets C++17; features from C++20 are labelled where they appear.
- C++ is not a strict superset of C: for example,
int *p = malloc(4);compiles in C but needs a cast in C++.
Key takeaways
- C++ adds classes, templates, exceptions and the STL to C.
- Programs start in
main;std::cout << valueprints. - Modern C++ (C++11 and later) is much safer and more expressive than C-style C++.
Try it yourself
- 1Print your name and branch on separate lines using a single
std::coutstatement. - 2Store three integers in a
std::vector<int>, sort them and print them.
Finished reading? Mark it complete to update your dashboard.
Suggested practice
3 questions test this exact topic. Answers and explanations are revealed after you submit.
- BeginnerWho created C++ and what was it first called?
- BeginnerWhich paradigms does C++ support?
- BeginnerWhat is printed?