Introduction: Why is C++ Relevant in 2025?
In 2025, C++ remains one of the most in-demand programming languages. It is used in game development (Unreal Engine), high-load servers, financial systems, operating systems, and embedded devices. Unlike Python, C++ gives you full control over memory and performance, which is critical for many projects.
This guide is created for those who want to start learning C++ from a practical perspective. We will cover environment setup, writing your first program, basic constructs, and common beginner mistakes. By the end of this article, you will be able to write and run your first meaningful C++ program.
Step 1: Installing the Compiler and Setting Up the Environment
To start working with C++ in 2025, you will need a compiler. The most popular option for Windows is MinGW-w64 (GCC environment). For macOS, Xcode Command Line Tools will work, and for Linux, the build-essential package.
Installing MinGW-w64 on Windows
- Download the installer from the official website
mingw-w64.org. - Run the installer and select the x86_64 architecture.
- Add the path to the
binfolder (e.g.,C:\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin) to the systemPATHvariable. - Verify the installation by running in the terminal:
g++ --version.
Checking the Compiler
After installation, open a terminal (command line) and enter:
g++ --versionYou should see information about the compiler version. If the command is not found, check the PATH variable.
Step 2: First Program "Hello, World!"
Traditionally, learning any language begins with printing a greeting. Create a file hello.cpp and write the following code:
#include <iostream>
int main() { std::cout << "Hello, World!" << std::endl; return 0;}How does it work?
#include <iostream>— includes the input/output library.int main()— the entry point of the program.std::cout— an object for console output.<<— the data transfer operator.std::endl— a newline character.return 0— signals successful completion to the system.
Compilation and Execution
In the terminal, navigate to the folder with the file and execute:
g++ hello.cpp -o hello.exehello.exeOn Linux/macOS, replace hello.exe with ./hello.
Step 3: Syntax Basics — Variables and Data Types
C++ is a language with strict static typing. This means the type of a variable must be explicitly specified and cannot change during execution.
Basic Data Types
| Type | Description | Example |
|---|---|---|
int | Integer number | int age = 25; |
float | Floating-point number (7 digits) | float price = 19.99f; |
double | Double-precision number (15 digits) | double pi = 3.1415926535; |
char | Single character | char grade = 'A'; |
bool | Boolean value (true/false) | bool isReady = true; |
Example Program with Variables
#include <iostream>#include <string>
int main() { std::string name = "Alexey"; int age = 30; double height = 1.85; std::cout <&