C++


C++ was based on the classic C langauge, which in turn was based on the ancient B. No A ever existed.
Until Visual Basic came out, C++ was the most used langauge.




The C++ Shell

Here's what the C++ shell would look like:


#include <iostream.h>
void main {
    cout << "Hello, World!!!" << endl;
return 0;
}


Here's the explanation:
The #include <iostream.h> tells the program that this is a IOStream C++ document.
The void main{ is the main sub for the file.
The cout << "Hello, World!!!" << endl; prints "Hello, World!!!" to the screen.
The return 0; ends the sub, in effect (The next line really does that).
And last and least, the } really signals the end.
NOTE: YOU MUST INCLUDE A SEMICOLON AT THE END OF EVERY LINE OF CODE BESIDES THE #INCLUDE AND CURLY BRACKETS!!!



Printing to the screen

As you saw in the last section, the cout statment is used to print to the screen.
The text you want to print will be enclosed in quotes like the "Hello World!!!" in the last example.



Variables

Variables are also used in C++. To declare a variable use the following code:

int number //declare a integer
char sentence() //declare a string
To input variables use the cin statment. Cin takes the following syntax:
cin >> name>> endl;



Sample C++ Games

Here's some sample C++ games:



Meteor Defence is copyright © 2001 Sams.Net.