Released · improving
Programming language · Since 1985
C++ is a compiled language that adds classes, templates and RAII to C's performance and hardware control, used from game engines to systems software.
C++ is a general-purpose programming language that Bjarne Stroustrup began at Bell Labs under the name "C with Classes". It stays largely compatible with C while adding classes, templates, exceptions and operator overloading, and its standard is now maintained by an ISO committee (WG21). Since C++11 a new standard has arrived roughly every three years, and with C++17 and C++20 a safer, more expressive style known as "modern C++" has become the norm.
C++ shines wherever you need fine control over performance and memory layout: game engines, web browsers, databases, compilers, trading systems and embedded devices, where latency and resource usage matter. Thanks to its zero-overhead principle, which means you don't pay for features you don't use, you can work with high-level abstractions and still get efficiency close to hand-written machine code.
If you are just starting, install a compiler for your platform (MSVC through Visual Studio on Windows, Clang from the Xcode Command Line Tools on macOS, g++ on Linux) and compile a few short programs yourself. Keep a beginner course such as learncpp.com at hand for the syntax and cppreference.com for the standard library. Getting used to std::vector, std::string and smart pointers from day one will save you from most manual memory-management mistakes.
Classes, templates and inline functions compile down to machine code close to what you would write by hand, and features you don't use cost nothing.
Destructors run automatically when an object goes out of scope, so memory, files and locks are released predictably without a garbage collector.
Templates let you write type-independent code, and the standard library supplies proven containers, algorithms, strings and threading primitives.
Mix procedural, object-oriented, generic and functional styles, while the standard keeps evolving with additions such as C++20 concepts and ranges.
On Windows, install Visual Studio and select the "Desktop development with C++" workload to get the MSVC compiler. On macOS, run xcode-select --install in Terminal to get the Xcode Command Line Tools (Clang). On Debian or Ubuntu Linux, install g++ and CMake with the command below.
sudo apt install build-essential cmakeOpen a new terminal and make sure the compiler prints its version. On macOS the g++ command points to Apple Clang. On Windows, open the Developer Command Prompt for VS and run cl to see the MSVC version.
g++ --versionCompile hello.cpp with the C++20 standard and warnings enabled, then run it. With MSVC on Windows, compile with cl /EHsc /std:c++20 hello.cpp and run hello.exe.
g++ -std=c++20 -Wall -Wextra -o hello hello.cpp && ./hello#include <iostream> brings in the standard input/output library. The main function is where the program starts, and the << operator sends the string to std::cout, which prints it to the screen. return 0 tells the operating system the program finished successfully. Passing -std=c++20 to g++ compiles against the C++20 standard, and the resulting hello binary is then run.
hello.cpp
#include <iostream>
int main() {
std::cout << "Hello, world!\n";
return 0;
}
g++ -std=c++20 -o hello hello.cpp && ./helloSix chapters that take you from installation to the core ideas of C++.
Ask questions, share experience and trade opinions about C++.
No discussions yet. Start the first one.
0 comments
Sign in · Sign in to leave a comment.
Be the first to comment.