Skip to content
Belajar C++

C++ Glossary

43 essential terms in C++ programming

Compilation (5 terms)

Bug

An error in a program that causes unintended behavior. Can be a compile error, runtime error, or logic error.

Compile Time

The process when your code is compiled by the compiler. Errors at this stage are called compile-time errors and prevent the program from running.

See also: Runtime

Compiler

A program that converts C++ source code into an executable file that the computer can run.

g++ hello.cpp -o hello
Runtime

When the program is actively running (executing). Errors that occur while the program runs are called runtime errors.

See also: Compile Time

Sintaks (Syntax)

The rules for writing code that must be followed. Like grammar in human languages — even one wrong character can cause an error.

Basics (9 terms)

#include

A directive that tells the compiler to include the contents of a header file in your program.

#include <iostream>
Ekspresi

A combination of values, variables, and operators that produces a value. Examples: `5 + 3`, `x * 2`, `a > b`.

Komentar

Text in code ignored by the compiler. Used to explain the code. `//` for single line, `/* */` for multiple lines.

// Ini komentar
Konstanta

Like a variable, but its value cannot be changed after it is set. Declared with the `const` keyword.

const double PI = 3.14159;

See also: Variabel

Namespace

A container that groups names (functions, variables, classes) to avoid naming conflicts. `std::` is the C++ standard namespace.

using namespace std;

See also: std

Operator

A symbol that performs an operation on values. Examples: `+` (add), `-` (subtract), `*` (multiply), `/` (divide), `%` (modulo), `==` (equal to).

Statement

A single complete instruction in C++, usually ending with a semicolon (`;`). Examples: `int x = 5;` or `cout << x;`.

std

The C++ standard namespace containing all built-in functions and objects like `cout`, `cin`, `string`, and more.

std::cout << "Halo";
Variabel

A named storage location in memory. Its value can change while the program runs.

int umur = 15;

See also: Konstanta

Data Types (6 terms)

bool

Boolean data type with only two values: `true` or `false`. Often used in conditions.

bool lulus = true;
char

Data type for a single character. Written with single quotes (`'`). Examples: `'A'`, `'5'`, `'!'`.

char huruf = 'A';
double

Data type for decimal numbers with high precision (64-bit). More accurate than `float`.

double pi = 3.14159265;

See also: float

float

Data type for decimal numbers with standard precision (32-bit). Uses less memory than `double` but less precise.

float suhu = 36.5f;

See also: double

int

Data type for whole numbers (no decimals). Examples: -10, 0, 42. Usually takes 4 bytes of memory.

int nilai = 90;
string

Data type for text (a sequence of characters). Written with double quotes (`"`). Requires `#include <string>`.

string nama = "Budi";

Flow Control (7 terms)

break

A command to forcefully exit a loop or switch, jumping directly to the code after the loop/switch block.

See also: continue

continue

A command to skip the rest of the current iteration and immediately move to the next iteration in a loop.

See also: break

do-while

A loop that always executes at least once, because the condition is checked at the end, not the beginning.

do { x++; } while (x < 10);

See also: while , for

for

A loop with three parts: initialization, condition, and update. Best when the number of iterations is known.

for (int i = 0; i < 10; i++) { ... }

See also: while , do-while

if-else

A branching structure that executes different code blocks based on a condition. If the condition is true, run the `if` block; otherwise run the `else` block.

if (nilai >= 70) { cout << "Lulus"; } else { cout << "Tidak lulus"; }
switch

Branching based on the exact value of a variable. An alternative to many `if-else` chains for discrete values.

See also: if-else , break

while

A loop that keeps running as long as its condition is `true`. The condition is checked first — if immediately false, the loop never executes.

while (x > 0) { x--; }

See also: for , do-while

Functions (9 terms)

Argumen

The actual value sent to a function when it is called. Arguments fill in the parameters defined in the function.

See also: Parameter

Fungsi

A named block of code that can be called multiple times. Allows code reuse and better organization.

int tambah(int a, int b) { return a + b; }

See also: Parameter , Return Value , Overloading

Overloading

Defining multiple functions with the same name but different parameters (type or count). The compiler automatically selects the right version.

See also: Fungsi , Parameter

Parameter

A variable declared inside the function's parentheses. Parameters receive values (arguments) when the function is called.

See also: Argumen , Fungsi

Pass by Reference

A way of passing arguments where a reference to the original variable is sent (using `&`). Changes inside the function affect the original variable.

void gandakan(int& x) { x *= 2; }

See also: Pass by Value

Pass by Value

A way of passing arguments to a function where a copy of the value is sent. Changes to the parameter inside the function do not affect the original variable.

See also: Pass by Reference

Return Value

The value returned by a function to its caller using the `return` keyword. The return type is written before the function name.

return a + b;

See also: void

Scope

The area in code where a variable can be accessed. Variables inside `{}` can only be accessed within that block (local scope).

See also: Variabel

void

A return type meaning the function does not return any value.

void sapa() { cout << "Halo!"; }

See also: Return Value

Array & Struct (3 terms)

Array

A collection of values of the same type stored sequentially in memory. Accessed using an index starting from 0.

int nilai[5] = {80, 90, 75, 95, 85};

See also: Indeks

Indeks

The position number of an element in an array. Always starts from 0, not 1. An array with 5 elements has indices 0 through 4.

See also: Array

Struct

A custom data type that groups several variables of different types into one unit. Used to represent real-world objects.

struct Siswa { string nama; int umur; double nilai; };

See also: Array

Input/Output (4 terms)

cin

The standard C++ input object for reading user input (keyboard). Used with the `>>` operator.

cin >> nama;

See also: cout

cout

The standard C++ output object for displaying text on screen. Used with the `<<` operator. Part of the `std` namespace.

cout << "Halo, Dunia!" << endl;

See also: cin , endl

endl

Moves to a new line in output. Besides moving to a new line, it also flushes the buffer. Alternative: `"\n"`.

cout << "Baris 1" << endl << "Baris 2";

See also: cout

File I/O

The ability to read and write data to/from files. Uses `ofstream` (output file) and `ifstream` (input file) from the `<fstream>` header.

ofstream file("data.txt");

See also: cout , cin

This glossary covers terms from Units 0–6. For fuller explanations with code examples, see the relevant lessons.