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:
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;
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.)
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
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
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.)
No comments:
Post a Comment