fundamentals January 10, 2026 2 min read

Introduction to C++

Getting started with C++ programming — compiler setup, basic syntax, variables, and your first program.

Introduction to C++

C++ is a powerful, high-performance programming language widely used in systems programming, game development, embedded systems, and competitive programming.

Your First Program

#include <iostream>

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

Variables and Types

C++ is a statically typed language:

int age = 25;              // Integer
double pi = 3.14159;       // Double precision float
char grade = 'A';          // Character
bool isActive = true;      // Boolean
std::string name = "Alice"; // String (requires <string>)

Input/Output

#include <iostream>
#include <string>

int main() {
    std::string name;
    int age;

    std::cout << "Enter your name: ";
    std::getline(std::cin, name);

    std::cout << "Enter your age: ";
    std::cin >> age;

    std::cout << "Hello, " << name << "! You are " << age << "." << std::endl;
    return 0;
}

Compilation

# Compile with g++
g++ -std=c++17 -o program main.cpp

# Run
./program

Key Differences from Python

FeatureC++Python
TypingStaticDynamic
CompilationCompiledInterpreted
MemoryManual/RAIIGarbage Collected
SpeedVery FastSlower
SyntaxVerboseConcise

Related Articles