HOW UNREAL THINKS · C++ BASICS

How to Read C++ Code: A Minimal Vocabulary for the Absolute Beginner

This article does not teach you to write code. It gives you exactly the minimal vocabulary of seven words — statement, variable, type, function, class, pointer, reference — without which the encyclopedia's next article (about reading an engine header file) will be incomprehensible from the very first sentence. If you have never written a single line of code in your life, read this article in full, without skipping anything. If you have already written code in any other language, still go through it: some of these words mean something slightly different in C++ than they do in other languages.

A slower, hands-on version of the same material

This article is a quick recognition vocabulary for reading code, not a step-by-step writing course. If you want the same material at a slower pace, with code you write yourself and verifiable practice at every step — the early stages of Learning cover statements, variables, types, and functions at exactly that pace before moving on to classes and pointers.

01What is it?

C++ source code is a text file that only looks intimidating until you can distinguish the individual, repeatedly occurring building blocks within it. There are few such blocks: statement, variable, type, function, class, pointer, reference. Each of them is not an abstract programming theory concept, but a concrete piece of text recognizable by its appearance. The goal of this article is not to tell you everything about C++ (that is impossible in a single article and unnecessary for reading code), but to give you exactly seven anchor points that your eye can latch onto when it sees an unfamiliar file.

02Why does it exist?

The problem: one line, five unfamiliar words

Imagine you opened a code file for the first time in your life and saw a single line:

float Health;

For a person who has never programmed, there is not a single familiar landmark here. Is float a word from mathematics? Is Health a command? Why is there a semicolon at the end if it is not the end of a natural-language sentence? Without answers to these questions, even one short line forces a complete stop, and real engine files are not one line but hundreds.

What exactly breaks

The problem is not that the task is difficult — the problem is that without a basic vocabulary, there is nothing to compare it to at all. A person who does not know the word "variable" cannot ask themselves the next, more precise question about that line — they get stuck on the very first incomprehensible symbol because they do not know which category of things to assign what they are seeing.

The reason: C++ is a language with a fixed, small set of written forms

Unlike natural language, where the same thought can be expressed in a thousand different ways, C++ has a strictly limited set of syntactic forms: a program is always a sequence of statements, every variable always has a type, every function is always declared in roughly the same way. This limitation is not a flaw — it is the direct reason why a vocabulary of seven concepts can cover the overwhelming majority of what you will encounter in a real file: there are few forms, and they constantly repeat.

03What problem does it solve?

After this article, any line of C++ code, even one unfamiliar in content, is recognized at least by its form: "this is a variable declaration", "this is a function call", "this is a pointer". This does not give you an understanding of Unreal's architecture (that requires the following articles at this level) — it gives you the ability to physically not get lost in the text, to distinguish where one thought of the code's author ends and the next begins.

04How is it structured?

Statement and the semicolon

A C++ program is a sequence of statements: individual, complete actions that the computer must perform one after another, top to bottom (unless something changes that order deliberately — but that is not covered in this article). The boundary between two adjacent statements is the semicolon ;.

🔤 How to read this in C++

The semicolon in C++ plays the same role as the period at the end of a natural-language sentence — it signals: "this thought is finished, a new one begins next." A forgotten semicolon is one of the most common mistakes for people who have just started writing code, because the compiler cannot figure out where one statement ends and the next begins, and it reports an error — but when reading code, which is the subject of this encyclopedia, the semicolon is, on the contrary, the most reliable landmark: when you see it, you can mentally put a period there and move on to the next thought.

Variable and type

A variable is a named location in the computer's memory where some value is stored, and that value can change as the program runs (hence the name — "variable", as opposed to a value fixed once and for all). Every variable in C++ has a type — a declaration of what kind of value can be stored in it at all: an integer, a fractional number, text, true/false, and so on. The type is written before the variable's name.

example — three variables of different typesC++
int Score;
float Health;
bool bIsAlive;
🔤 How to read this in C++

int — the type for whole numbers without a fractional part (1, 42, -7). float — the type for numbers with a fractional part (3.14, 0.5, -12.75). bool — a type that can only store one of two values: true (true) or false (false) — used for "yes/no" questions (for example, "is the character alive?"). After the type comes the variable's name — how the rest of the code will refer to that location in memory. Each line is a separate statement, so each ends with a semicolon.

The type matters not only to the person reading the code — the compiler uses it to catch meaningless operations ahead of time, before the program runs (for example, an attempt to add text to a boolean value), and to figure out exactly how much memory space to allocate for each variable.

Function: declaration, definition, call, parameters, return

A function is a named, reusable piece of code that performs a specific action and can be run ("called") from any other place in the program, not just once at the place where it is written. A function has three distinct aspects that beginners often confuse: the declaration — a written description of the function's form without its contents; the definition (or "implementation") — the same header, but together with the actual code inside curly braces; and the call — a specific place in the code where this function is asked to execute right now.

declaration, definition, and call of the same functionC++
// Declaration — the contract "such a function exists", without a body:
int AddDamage(int BaseDamage, int Bonus);

// Definition — the same header, but with a body in curly braces:
int AddDamage(int BaseDamage, int Bonus)
{
    return BaseDamage + Bonus;
}

// Call — using the function in another place in the code:
int TotalDamage = AddDamage(10, 5);  // TotalDamage is now 15
🔤 How to read this in C++

int AddDamage(int BaseDamage, int Bonus) — the first int here means the return type: what type of value this function gives back to the code that called it when it finishes working. Everything inside the parentheses — parameters: named values that the function receives from the outside on each call and uses inside itself like ordinary variables; here there are two of them, BaseDamage and Bonus, both of type int. The word return inside the function body ends its execution and hands the value specified after it back to the outside — to the place where the function was called from. In the call line AddDamage(10, 5), the numbers 10 and 5 are substituted into the places of the parameters BaseDamage and Bonus, respectively, in the same order in which the parameters are listed in the declaration.

Why this distinction matters for reading, not just for writing

In real engine files, a function's declaration and its definition are almost always physically located in different files — the declaration in a header .h, the definition in a .cpp. If you see a line ending with a semicolon right after parentheses with parameters, without curly braces containing code — that is a declaration, and the actual logic of the function is physically located not here, but somewhere else. This is not "unfinished" code — it is a normal, ubiquitous written form in C++, and the encyclopedia's next article examines it using a real engine file.

Class and object

A class is a description of some entity: what variables it has (in the context of a class they are called fields) and what functions (called methods) it can perform. A class by itself is not a finished thing, but a blueprint. An object (or instance of a class) is a concrete entity built from that blueprint in memory while the program runs. One class can produce any number of different objects, each with its own field values.

a class as a blueprintC++
class FCharacterStats
{
public:
    int Health;
    int Mana;
};
🔤 How to read this in C++

The word class opens the description of a new class, followed by the name it was given (FCharacterStats). The curly braces { ... } delimit the body of the class — everything related to its description; the semicolon immediately after the closing } is mandatory for a class, unlike, for example, a function body. The word public: is an access section: everything declared below it is accessible to any code that has access to this class at all (access sections also have more restrictive variants, but for a first reading it is enough to know that they exist and regulate who can see a field or method). Inside are two fields, Health and Mana, each with its own type, declared exactly like the ordinary variables from the variables section, except now they belong not to one individual statement but to an entire class.

If somewhere later in the code there appears FCharacterStats PlayerOne; and FCharacterStats PlayerTwo; — these will be two separate objects of the same class, and each has its own, mutually independent values of Health and Mana. Changing one's health will not affect the other's — just as two houses built from the same architectural blueprint remain two different, physically independent buildings.

Pointer and reference

An ordinary variable stores a value directly. A pointer stores not the value itself, but an address — the place in the computer's memory where that value actually lies. In C++, a pointer is denoted by an asterisk * after the type.

ordinary variable vs pointerC++
int Score;        // ordinary variable — stores the number itself
int* ScorePtr;     // pointer — stores the ADDRESS of a variable, not the number
🔤 How to read this in C++

int* ScorePtr; — the asterisk immediately after the type means: ScorePtr does not store an integer directly, but an address in memory at which that integer can be found. A pointer can be compared to a piece of paper on which a house's address is written, rather than the house itself — with that piece of paper you can go to the house and change something in it, but the piece of paper itself is not the house. A pointer has a special value nullptr — "a pointer that leads nowhere": an address at which nothing is known to lie, and code using the pointer must be prepared for this case before trying to follow it.

A reference works similarly — it also does not store a value directly, but refers to an already existing variable, — but unlike a pointer, it is denoted by an ampersand &, cannot be "pointing nowhere" (nullptr is impossible for a reference), and does not require a separate step to get to the value — it behaves like a second name for an already existing variable.

Why the language has two different tools that at first glance do a similar thing is a question of code architecture, not syntax reading, and it is examined in detail in the encyclopedia's following articles using real engine examples. Here it is enough to be able to tell one symbol from another on the page: * — pointer, & — reference.

const

The word const is a promise to the compiler not to change whatever it refers to. The compiler checks this promise itself: if the code still tries to change something marked const, the project build will stop with an error before the program even runs.

const on a variableC++
const int MaxPlayers = 4;  // this value cannot be changed anywhere later in the code

const can appear in different places in a line and mean slightly different things — for example, on a function parameter it means "the function will not change the value passed to it", and at the very end of a class method declaration it means "calling this method will not change the fields of the object itself". The exact meaning of each specific case is the subject of the following articles, where it will be examined directly on real engine code; here it is important only not to be afraid of the word itself and to know that it always means some kind of prohibition on change, and not something else.

05When to stop at each word, and when to skim

Worth stopping and parsing with this article's vocabulary when…You can skim when…
The line uses a written form unfamiliar to you — you cannot immediately say whether it is a variable, a function, or something elseYou have already recognized the line's form (for example, "this is a variable declaration") — there is no need to delve into each such repetition anew
You see an asterisk * or an ampersand & next to a type and are not sure what it changesA comment in the code (text after //) already explains the line's meaningful sense — syntax is secondary in that case
The function or class is part of the code you are going to use or modifyYou are simply assessing the overall scale of an unfamiliar file (see the next article about reading headers) — at that stage it is not every line that matters, but the overall structure

How this can be abused

The opposite extreme is just as real: trying to learn C++ syntax fully, in every detail, before opening a single real engine file. The C++ language is large enough that fully learning it "in reserve" takes considerably more time than practically reading specific files as needed — and details that never came up even once in a month of practice are unlikely to be needed anytime soon. The seven concepts in this article cover the overwhelming majority of what actually appears in engine headers at the level of "read and understand the form" — the rest is worth picking up as you go, on concrete examples, rather than in advance and in the abstract.

06Common mistakes

Beginner mistake: confusing a function declaration with a function call

The lines int AddDamage(int BaseDamage, int Bonus); (declaration) and AddDamage(10, 5); (call) look similar — both contain the function's name and parentheses — but they mean fundamentally different things: the first describes the function's form once, the second starts its execution at a specific place in the program, and there can be as many such calls in the code as you like. Having confused them, a beginner sometimes looks for the function's "real code" where in fact there is only another call — and a call by itself contains no logic; it merely refers to an already existing definition.

Beginner mistake: considering a pointer and an ordinary variable interchangeable

Since int Score; and int* ScorePtr; differ in writing by one character, it is easy to decide that the difference is purely formal. In reality, accessing a value through a pointer requires a separate step (you need to "follow" the address to get to the number itself), and the pointer itself may turn out to be nullptr — and an attempt to access via a null address crashes the program. A one-character difference in writing is a fundamental difference in behavior, and the following articles examine it using real, not educational, examples.

How a senior reasons

A senior does not hold the entire formal grammar of C++ in their head — they hold exactly the same small set of recognizable forms examined in this article, and they recognize them automatically, without thinking, just as an experienced reader does not spell out every word in a book in their native language. The difference between a beginner and an experienced developer at this level is not the amount of knowledge about the language, but the speed and automaticity of recognizing the same seven forms that appear again and again.

07Practice

Task — name the form of each line
Below are four lines of code. For each, determine: is it a variable declaration, a function declaration, a function call, or a pointer?
1) bool bIsAlive;
2) AActor* Target;
3) void TakeDamage(int Amount);
4) TakeDamage(25);
Show the expected line of reasoning

(1) Declaration of an ordinary variable of type bool — the name is bIsAlive, there is no asterisk, so it is not a pointer. (2) Declaration of a pointer — the asterisk immediately after the type AActor means that Target stores an address, not the AActor object itself. (3) Declaration of a function without a body — a semicolon immediately after parentheses with a parameter, no curly braces with code, so it is a contract, not a definition. (4) Function call — the same name TakeDamage, but now with the concrete value 25 instead of a parameter description, and this is no longer a description, but a command to "execute right now".

08Frequently asked questions

?After this article, do I need to be able to write C++ code?

No — this article and this entire encyclopedia start with reading, not writing. The ability to recognize a variable, function, class, and pointer on a page is a necessary but independent skill that does not require the ability to write the same thing from scratch. Writing code comes later, naturally, after enough read and understood examples have accumulated.

?What should I do if a real engine file contains a construct that is not among these seven concepts?

That is expected and will almost certainly happen — C++ is considerably larger than seven concepts, and Unreal adds its own macros on top. The correct reaction is not to panic and not to try to learn the whole language in advance, but either to read the corresponding article of this encyclopedia, where the new construct first appears and will be explained on the spot (by this project's rule, every article explains a construct new to it itself, without sending you to look for it elsewhere), or, for an isolated case, to look up the meaning separately and return to reading.

?Why do the examples in this article not use real engine code?

Because the goal of this particular article is the C++ language itself in its pure form, without the additional layer of Unreal's macros and architectural decisions that would otherwise distract attention from what is truly important here: the seven basic forms. Real engine code annotated with these same seven concepts is the subject of the next article, "How to Read an Engine .h File".

09What the reader should start noticing

After this article, an asterisk and an ampersand next to a type stop being an insignificant stroke and start reading as an explicit signal of "pointer" or "reference" — things with different behavior, not two similar symbols. A semicolon without curly braces after a function's parentheses starts to be perceived not as truncated code, but as a recognizable sign of a declaration without a definition. And any unfamiliar line of code now gets sorted first of all by the same simple question — "is this a variable, a function, a class, or one of these seven forms" — instead of provoking a general feeling of "too complicated, I won't figure it out".

10Summary

  • ✔ recognize a statement and the boundary between statements by the semicolon
  • ✔ distinguish a variable and its type, state the difference between int, float, and bool
  • ✔ tell apart a function declaration, its definition, and a call — by the presence of a semicolon without a body, a body in curly braces, or concrete values instead of parameters
  • ✔ explain in your own words the difference between a class as a blueprint and an object as a concrete entity built from that blueprint
  • ✔ by a single symbol (* or &) tell a pointer from a reference on a page of code
  • ✔ understand that const is always some kind of prohibition on change, checked by the compiler in advance
  • ✔ by the symptom ("I don't understand a word in this line") figure out which of the seven concepts is missing, instead of the general feeling of "too complicated"
💡 Senior Thoughts

The seven concepts in this article are not an initial, temporary stage that you outgrow. They are the same vocabulary an experienced developer uses every day, just brought to automaticity. Don't try to memorize them as a list — better to return to this page once more after you read the next article on real engine code: a second pass over the same seven words, but this time on a real example, cements them much faster than trying to learn them by heart here and now.

Material prepared for UE C++ Academy. Original article — uecppacademy.com. If this material helped you understand Unreal Engine — you can support the project's development.

© 2026 UE C++ Academy. All rights reserved. For copyright or technical issues — support@uecppacademy.com