C++ Tutorial 1: The Basics

C++ Tutorials: Basics[/i

C++ is an interesting language. It is very powerful and very expandable. C++ has 5 basic types:

char

string

int

float

double

These all can contain different things.

ints contain integers.

floats contain integers with decimals

doubles can contain either ints or floats

string contains a string or characters (or chars)

char contains a character (and an array of characters when defining them a special way, more on this later).

In C++ there are things called functions:

Code

someType SomeFunctionName(FunctionParameterType FunctionParameterName)
{
    // do something here
}




Comments are lines which are used to explain what a certain line does or prevent code from being compiled or used (in the case of a header file).

In C++ there is also something called classes. Classes are containers for functions and are used for objects. An object could be a keyboard handler, a robot in a game or a type called a string. 🙂

We will talk about classes later on.

C++ also has namespaces. Namespaces are used to organize functions, classes, and variables for a certain thing. For example. A namespace called level1 may contain the following:

Function loadLevel();

Variable LevelSavePoint;

And Class Level1;

More on namespaces later.

In C++ we also use semicolons ( ; ). These mark the end of a line of code. These semicolons (unlike in BASIC) allow use to do things like the following;

Code

int semicolonexample = 0; semicolonexample++;




as you can see with semicolons you can compress multiple lines into one if you really want to (though I discourage this and will frown at you if you do this in FrostOS if you do not have a very very good reason
to.)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s