Navigation



8.2 — Classes and class members

While C++ provides a number of basic data types (eg. char, int, long, float, double, etc…) that are often sufficient for solving relatively simple problems, it can be difficult to solve complex problems using just these types. One of C++’s more useful features is the ability to define your own data types that better . . . → Read More: 8.2 — Classes and class members

8.1 — Welcome to object-oriented programming

All of the previous lessons up to this point have one thing in common — they have been non-object-oriented. Now that you have a basic handle on those concepts, we can proceed into object-oriented programming (OOP), where the real payoff is!

In traditional programming, programs are basically lists of instructions to the computer that . . . → Read More: 8.1 — Welcome to object-oriented programming

7.11 — Namespaces

Namespaces don’t really fit into the functions category, but they are an important concept that we need to cover before we get to classes and object oriented programming, and this is really as good a place as any.

Pretend you are the teacher of a classroom of students. For sake of example, let’s say . . . → Read More: 7.11 — Namespaces

7.10 — Recursion

A recursive function in C++ is a function that calls itself. Here is an example of a poorly-written recursive function:

void CountDown(int nValue) { using namespace std; cout << nValue << endl; CountDown(nValue-1); } int main(void) { CountDown(10); return 0; }

When CountDown(10) is called, the number 10 is printed, and CountDown(9) is called. . . . → Read More: 7.10 — Recursion

7.9 — The stack and the heap

The memory a program uses is typically divided into four different areas:

The code area, where the compiled program sits in memory. The globals area, where global variables are stored. The heap, where dynamically allocated variables are allocated from. The stack, where parameters and local variables are allocated from.

There isn’t really much to . . . → Read More: 7.9 — The stack and the heap