Cambo Freelance
ទំព័រដើមសេវាកម្មអត្ថបទការបង្រៀនក្រុមវគ្គបណ្តុះបណ្តាលទំនាក់ទំនង
Cambo Freelance

Professional freelance team from Cambodia delivering technology-driven solutions with cultural insight and modern expertise.

ផ្ញើសាររបស់អ្នក

ត្រៀមចាប់ផ្តើមគម្រោងរបស់អ្នក? ទំនាក់ទំនងក្រុមរបស់យើង។

ទំនាក់ទំនង

សេវាកម្ម

  • Web & Mobile Development Services
  • Graphic Design & Branding Services

តំណភ្ជាប់មានប្រយោជន៍

  • ទំព័រដើម
  • សេវាកម្ម
  • ការសិក្សា
  • អំពីយើង
  • ទំនាក់ទំនង
  • តម្លៃ

© 2026 Cambo Freelance. រក្សាសិទ្ធិទាំងអស់។

TelegramFacebookLinkedInEmail
HomeTutorialsC++C++ Getting Started
⚡C++ Tutorials

50 lessons

Beginner(21)1C++ Introduction2C++ Getting Started3C++ Syntax4C++ Output5C++ Comments6C++ Variables7C++ Data Types8C++ Constants9C++ User Input10C++ Operators11C++ Strings12C++ Math13C++ Booleans14C++ Conditions15C++ Switch16C++ Loops17C++ Break and Continue18C++ Arrays19C++ Functions20C++ References21C++ Pointers
Intermediate(19)22C++ Classes23C++ Objects24C++ Constructors25C++ Access Specifiers
Advanced(10)41C++ Smart Pointers42C++ Templates43C++ Lambda Functions44
⚡

C++ Tutorials

Lesson 2 of 50

All lessons
Beginner (21)1C++ Introduction2C++ Getting Started
26
C++ Encapsulation
27C++ Inheritance
28C++ Polymorphism
29C++ Abstraction
30C++ Files
31C++ Exception Handling
32C++ Namespaces
33C++ Structures
34C++ Enumerations
35C++ STL Introduction
36C++ Vectors
37C++ Maps
38C++ Sets
39C++ Queues
40C++ Stacks
C++ Move Semantics
45C++ Multithreading
46C++ Design Patterns
47C++ Memory Management
48C++17 Features
49C++20 Features
50C++ Performance Optimization
3
C++ Syntax
4C++ Output
5C++ Comments
6C++ Variables
7C++ Data Types
8C++ Constants
9C++ User Input
10C++ Operators
11C++ Strings
12C++ Math
13C++ Booleans
14C++ Conditions
15C++ Switch
16C++ Loops
17C++ Break and Continue
18C++ Arrays
19C++ Functions
20C++ References
21C++ Pointers
Intermediate (19)22C++ Classes23C++ Objects24C++ Constructors25C++ Access Specifiers26C++ Encapsulation27C++ Inheritance28C++ Polymorphism29C++ Abstraction30C++ Files31C++ Exception Handling32C++ Namespaces33C++ Structures34C++ Enumerations35C++ STL Introduction36C++ Vectors37C++ Maps38C++ Sets39C++ Queues40C++ Stacks
Advanced (10)41C++ Smart Pointers42C++ Templates43C++ Lambda Functions44C++ Move Semantics45C++ Multithreading46C++ Design Patterns47C++ Memory Management48C++17 Features49C++20 Features50C++ Performance Optimization
⚡C++BeginnerLesson 2 of 50CamboFreelanceJune 19, 2026

C++ Getting Started

Set up your C++ development environment. Learn how to install a compiler, choose an IDE, and compile and run your first C++ program.


Tutorials › C++ › Getting Started
Beginner6 min readLesson 2 of 50

In This Lesson

  • Install a Compiler
  • Choose an IDE
  • Compile & Run
  • Quiz
  • Summary

Step 1 — Install a C++ Compiler

A compiler converts your C++ source code into an executable program. The most common compilers are:

CompilerPlatformNotes
GCC (g++)Linux / macOS / WindowsFree, open-source, most widely used
ClangmacOS / Linux / WindowsFast, excellent error messages
MSVCWindowsBuilt into Visual Studio

Install on Windows (MinGW/GCC)

  1. Download MSYS2 from msys2.org.
  2. Open the MSYS2 terminal and run: pacman -S mingw-w64-x86_64-gcc
  3. Add C:\msys64\mingw64\bin to your PATH environment variable.
  4. Verify: open Command Prompt and type g++ --version

Install on macOS

xcode-select --install

This installs Clang (Apple's C++ compiler). Verify with clang++ --version.

Install on Linux (Ubuntu/Debian)

sudo apt update
sudo apt install g++

Step 2 — Choose an IDE or Editor

IDE / EditorBest For
Visual Studio CodeLightweight, cross-platform, great extensions
Visual StudioWindows, full-featured, built-in MSVC
CLionProfessional C++ development (paid)
Code::BlocksBeginners, lightweight, free
Online: cpp.shNo install needed, browser-based

Step 3 — Compile and Run Your First Program

Create a file named hello.cpp with the following code:

#include <iostream>
using namespace std;

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

Open your terminal, navigate to the file location, then compile and run:

g++ hello.cpp -o hello
./hello

Output:

Hello, World!
Note: The -o hello flag names the output executable hello. On Windows the output will be hello.exe.

Exercise

Create a file myprogram.cpp that prints C++ is awesome! and compile it using g++.

Show Solution
#include <iostream>
using namespace std;

int main() {
    cout << "C++ is awesome!" << endl;
    return 0;
}
g++ myprogram.cpp -o myprogram
./myprogram

Quiz

  1. What does a compiler do?

    • A) Edits code
    • B) Converts source code to an executable
    • C) Runs code line by line
    • D) Manages memory
    Answer

    B) A compiler translates your C++ source code into machine code (an executable).

  2. Which command compiles a file named main.cpp using g++?

    • A) run main.cpp
    • B) cpp main.cpp
    • C) g++ main.cpp -o main
    • D) compile main.cpp
    Answer

    C) g++ main.cpp -o main compiles the file and names the output main.

Summary

  • You need a compiler (GCC/g++, Clang, or MSVC) to run C++ programs.
  • C++ source files use the .cpp extension.
  • Compile with g++ filename.cpp -o output, run with ./output.
  • Online compilers like cpp.sh let you practice without installing anything.
← Previous: Introduction Next: C++ Syntax →
c++setupcompilergccbeginner
PreviousLesson 1: C++ IntroductionNextLesson 3: C++ Syntax
Back to All Tutorials