Category Archives: C++


C++ is if you didn’t know an Object Oriented programming language, a programming paradigm that represents concepts as “objects” that have data fields (attributes that describe the object) and associated procedures known as methods. Objects, which are usually instances of classes, are used to interact with one another to design applications and computer programs.

With this comes other versions of programming, such as:

Java: This is a

.Net Framework: This

Data Types

The sort of information a variable can store is determined by it’s data type, such as int.

The 3 most common data types used are:

Integers (Whole numbers)

non-integral values (floating point types)

void (An empty set of values or no type)

*All these data types are within the program and are specified by particular keywords

As you know Integers can only hold whole numbers both positive and negative and it normally is around 4 bytes in memory.

Other versions of int are:

short int

long int

which we will come across soon.

Defining Variables

Names: The name of a variable is known as an identifier. These names can include the letters A-z (both upper and lower case) and the digits 0-9. It can also have _ (underscore) if needed.

Each variable name can be up too 2048 characters but it is best to limit them to 31 characters as some compiles cannot run them.

Now you know how to name them, this next part will describe them.

A variable is used to store small bits of information such as the size of something, for example:

int size_of_house = 10;

The size_of_house variable is set at 10

The int at the beginning just tells C++ that the variable is an integer or whole number.

Another way to write this is: int size_of_house(0);


Statement Blocks

Statement blocks is a term used to describe a block of text that sit between the {}. So:

int main () {

This is a statement block


but you can have several statement blocks all sitting within one another which gives the statement block depth, like so:

int main () {

this is a statement block

text {

more text




A term used in C++ to describe the black spaces is whitespace.

Whitespace can be anything from the a space between words, symbols and code.

It can also be the space that is empty just because the code doesn’t fill the page, but be careful as some whitespace is not allowed and will throw up errors. For example:

std::cout<<”hello world”<<endl; will work

std :: cout << “hello world” << endl; will work

std::c out<<”hello world”<<endl; will not work

Other files

In C++ there are other file types apart from .cpp (C++) and .h (header).

.ilk which are linker files, these automatically re-link object files to any modified code.

.pdb files, which are debug files. These allow you too inspect the information generated when the program is executed and make changes if necessary.

.ico files are icon files which are displayed when the program is minimized

.rc files record the resources for the application


Simple line of code

In C++ we can create the same new world project as in C, it is just written differently like so:

std::cout<<”hello world”<<endl;

This is a very expanded version of this code just so I can go through the whole understanding of C++.

The std:: cout is used to initiate the identifier cout, and is the common output stream for C++.

Now these << symbols are what c++ read as output operator, each item such as string, function, statement, ect, has to have its own << to let the program know it is to be outputted to the command console.

The ” indicate the string as with C

endl is a new feature in C++, as with C you use the \n for a new line character C++ uses endl…. it does the same thing as \n.

* C++ can use \n as well but the endl function is a bit more easier to read.

C++ Text (Namespace 2)

However what I just went over in the previous post is very common it may not be used in some projects to stop confusion.

It can cause confusion because ()

The other way you may see identifiers in the standard namespace being used are:


This tells the compiler that you want to use the cout identifier in the standard namespace.

In this bit of code there is something new a, :: These double colons are known as a scope and it tells the compiler which namespace to look into.