← About this resource

T.O.P. Learning / Recovered adventures

C++ Forge

Travel from the Welcome Gate to the Segmentation Dragon. This study edition preserves the fifteen zones, examples, and multiple-choice challenges of the terminal adventure. It does not compile or execute code.

15 chapters · 35 challenges · no account needed

Study at your pace. Answers are checked as text, never executed. Only completed challenge IDs are saved in this browser; no answers or personal information are stored or sent.

Loading challenges…

Lesson notebook

Open a chapter to read or revisit its notes.

Welcome Gate

You arrive at the Welcome Gate. The kingdom is powered by source code,

but source code does not run by itself. A compiler translates C++ into

a program the machine can execute.

Your first repair spell:

#include <iostream>

int main() {
    std::cout << "Hello, C++!" << std::endl;
    return 0;
}
Variable Village

Variable Village is trying to store supplies. In C++, a variable has

a type, a name, and often a value. The type tells the compiler what

kind of data lives there.

int apples = 10;
double price = 2.99;
char grade = 'A';
bool isReady = true;
std::string name = "Shiva";
Input Forest

Input Forest only opens when you speak to it. C++ usually reads one

word or number with std::cin. For a full line with spaces, use

std::getline(std::cin, value).

std::string tool;
std::cout << "Favorite tool: ";
std::getline(std::cin, tool);
Operator Mines

Operator Mines are full of math crystals. C++ uses +, -, *, /, and

% for remainder. When both sides of / are integers, C++ keeps the

integer part and drops the decimal.

int a = 10 / 3;  // 3
int b = 10 % 3;  // 1
bool open = level >= 5 && hasKey;
Branching Woods

Branching Woods changes path based on conditions. if runs a block

when a condition is true. else handles the fallback path.

if (level >= 5) {
    std::cout << "Gate opened";
} else {
    std::cout << "Train more";
}
Loop Desert

Loop Desert is crossed by repeated steps. while loops keep going

while a condition is true. for loops are great when you know the

count. Range-based for loops walk through collections.

while (steps < 10) {
    steps++;
}

for (int i = 0; i < 5; i++) {
    std::cout << i;
}

for (const auto& item : inventory) {
    std::cout << item;
}
Function Tower

Function Tower teaches reusable spells. A function can take

parameters, return a value, or be void when it performs an action

without returning a value.

void sayHello() {
    std::cout << "Hello";
}

int add(int a, int b) {
    return a + b;
}
Vector Harbor

Vector Harbor loads cargo that can grow as the adventure grows.

Arrays are fixed-size containers. std::vector is flexible and often

friendlier for beginner programs.

#include <vector>
#include <string>

std::vector<std::string> tasks;
tasks.push_back("Learn C++");
std::cout << tasks.size();
String Library

String Library keeps scrolls of text. std::string supports joining

text, checking length, testing empty, and reading individual

characters by index.

std::string first = "Tree";
std::string second = "Forge";
std::string title = first + " " + second;
std::cout << title.length();
Reference Shrine

At the Reference Shrine, you learn the difference between working

on a copy and working on the original. A reference is another name

for an existing variable.

void increase(int& number) {
    number++;
}

int level = 4;
increase(level);  // level becomes 5
Pointer Caverns

Pointer Caverns are precise, not mystical. Every variable lives at

a memory address. A pointer stores an address. Dereferencing looks

at the value stored at that address.

int x = 10;
int* ptr = &x;
std::cout << *ptr;  // prints 10
Class Castle

Class Castle organizes data and behavior together. A class is a

blueprint. An object is a built thing made from that blueprint.

class Hero {
public:
    std::string name;
    int level;

    void introduce() {
        std::cout << "I am " << name;
    }
};

Hero player;
player.name = "Shiva";
player.level = 1;
Header Hall

Header Hall keeps spell books organized. Small programs can live in

one file, but larger programs split declarations and definitions.

main.cpp        // uses the functions
calculator.h    // declares the functions
calculator.cpp  // defines the functions
Debugging Dungeon

Debugging Dungeon is where C++ gets real. Compiler errors are clues,

not insults. Read the first useful error, check the line near it,

and look for tiny mistakes like missing semicolons, wrong includes,

= instead of ==, unsafe pointers, or vector indexes out of range.

std::cout << "Hello"
// Missing semicolon above

if (choice = 1) {
    // Assignment, not comparison
}

items.at(20);
// Throws if the vector is not that large
Boss Fight: The Segmentation Dragon

The Segmentation Dragon wakes under the final compiler gate. This

boss checks the whole road: compiling, output, vectors, functions,

classes, and memory safety.