Editing

Game Iterator

edit SideBar

C

C++

C++ is a complex object orientated programming language. It is widely used in games because it can generate fast code and it is possible to influence its low level behavior easily.


C++ QUICK START

oRobot

Let’s learn by example while briefly explaining. We will start with the ubiquitous “Hello World” Program. Start a new Console Application and type this code.

   // Another hello world program
   #include <iostream>

   using namespace std;

   int main()
   {
     cout << "Hello world!" <<endl;
     return 0;
   }

Line 1.)
This is just a comment. Anything typed after “//” on the same line is considered a comment. Basically this is used to put notes along with your code so you and everyone else that looks at your code knows what you’re doing or trying to do.

Line 2.)
This is something we need in order to do input and output stuff in our program. In the case of this small program outputting the text "Hello World!" to the screen.

Line 4.)
We’re going to be using a the standard library. Once again for now just always include this.

Line 6.)
"int main( )" This is where the initial execution of our program begins. It says do everything between the open bracket “{“ on “Line 7.”and the closed bracket “}” on “Line 10.”.

Line 8.)
“cout” tells the program that it is outputting to the screen. If you are outputting text to the screen you must always put it between quotes. Then “endl” just says to put the cursor to the next line after outputting.

Line 9.)
“return 0” just means to return nothing. You may be saying to yourself nothing…but were returning “Hello World!” to the screen. What we mean is “Hello World!” may be going to the screen but were not needing to return anything to use later. More about this when learning about functions.

Line 10.)
As was already mentioned before "}" this is where we close our bracket. See Line 6.) description.

This section needs to be extended. Please help.

Recent Changes (All) | Edit SideBar Page last modified on January 17, 2008, at 09:37 PM Edit Page | Page History
Powered by PmWiki