C++ History and Versions
The story of C++ is the story of making C better for big programs.
Short timeline
| Year | Event |
|---|---|
| 1979 | Bjarne Stroustrup starts “C with Classes” at Bell Labs |
| 1983 | The name is changed to C++ (the ++ is the increment operator of C) |
| 1985 | First commercial release and the book “The C++ Programming Language” |
| 1998 | First ISO standard: C++98 |
| 2011 | C++11: the “modern C++” starts |
| 2020 | C++20: a very big update |
| 2023 | C++23: the newest published standard |
What the standards added
| Standard | Important features |
|---|---|
| C++98 / C++03 | Classes, templates, exceptions, STL, namespaces |
| C++11 | auto, lambdas, nullptr, move semantics, smart pointers, range for, constexpr, threads |
| C++14 | Generic lambdas, make_unique, small fixes |
| C++17 | Structured bindings, std::optional, std::variant, std::string_view, if constexpr, filesystem |
| C++20 | Concepts, ranges, modules, coroutines, std::format, spaceship operator <=> |
| C++23 | std::print, std::expected, std::mdspan, deducing this |
Which standard do you use?
You tell the compiler with a flag. All these were tested with the real compiler:
$ g++ -std=c++23 –version | head -1
g++ (GCC) 16.2.0
$ echo 'int main() { auto f = [](auto x) { return x; }; return f(0); }' > t.cpp
$ g++ -std=c++11 t.cpp -o t11 2>&1 | head -3
t.cpp: In function 'int main()':
t.cpp:1:26: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14'
1 | int main() { auto f = [](auto x) { return x; }; return f(0); }
$ g++ -std=c++14 t.cpp -o t14 && echo "generic lambda works in C++14"
generic lambda works in C++14
In C++11 the generic lambda (auto x) is not allowed, and the compiler complains. In C++14 and newer it works.
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |