by LoveChild

Hello world, this will be my ploy for greatness... well at least I'll try and do a complete walkthrough of C++. This will take about 2 years, but in only a few lessons time you will be developing small useful programs.
First the basics, due to this being a class I take as a part of my engineering education, I'm forced to use Windows and Microsoft Visual C++ to develop programs. But as C++ is a multiplatform language you would have no problem writing code in say, kdevelop instead.
I would recomment that you install a version of kdevelop or at least a version of VIM or another text editior that supports systax highlighting as this will solve most of the problems you will have when writing code. Plus it makes it easier to read.
You will need a debugger, luck has it that the GNU debugger is one of the better ones available, soo if you develop in Linux you should install it. If you use a development suit like Kdeveloper you will be able to build, debug and write in the same application, which is very helpful.
For my class I have bought Deitels : C++, how-to program. therefore most of the exsamples will be from this book.
Let's start with a few lines of code... you should be able to cut'n'paste them into your development suit.
We'll start with explaining the basics of the long loved "Hello World" program
Code:
  // Hello World application

int main ()
{
std::cout << "Hello World\n";
return 0;
}
if you compile and run this it will display the message " Hello World "(and a new line) on your screen.
The way this works is that this: // makes the rest of the line a comment, not to be compiled - We like to comment as muchof our code as possible because it makes it easier to understand and read.
We define our main function, more on this later..
we tell the compiler that we need to include the iostream header file, which allows us to access the iostreams, useful for accessing information from the keyboard for user inputs and very useful for dumping things to the screen
Then we dump the text in the qoutationmarks Hello World plus a new line with the command \n. in this case we dump to std::cout which is the display, also called standard out.
Notice the semicolon at the end of each line, we put them there to tell the compiler that is the end of a statment. Forgetting to do this is a very common mistake.
The return 0; statment tells the compiler the the main function (we defined this one in the int main() line) is done, soo this means that the program has ended, hopefully succesful
As you will have noticed, the main function has been "embrassed" in brachets like these { } braces which limit the function to this area only...
Ok... that wasn't that hard... right?
As we have seen the \n code is newline but we can have even more fun with these commands:
Code:
\n Newline. Position the screen cursor to the beginning of the next line.
\t Horizontal Tab. Moves the cursor to the next tab stop.
\r Carriage return. Position the screen cursor to the beginning of the current line; 
  does not advance to the next line.
\a Alert. Sounds the system bell.
\\ Backslash. Might be helpful to be able to print the backslash character.
\" Double Quote. Prints the double qoute character.
Lets have even more fun, shall we?
Lets make our very first real program... Whoa
if you compile and run this it will display the message " Hello World "(and a new line) on your screen.
The way this works is that this: // makes the rest of the line a comment, not to be compiled - We like to comment as muchof our code as possible because it makes it easier to understand and read.
We define our main function, more on this later..
we tell the compiler that we need to include the iostream header file, which allows us to access the iostreams, useful for accessing information from the keyboard for user inputs and very useful for dumping things to the screen
Then we dump the text in the qoutationmarks Hello World plus a new line with the command \n. in this case we dump to std::cout which is the display, also called standard out.
Notice the semicolon at the end of each line, we put them there to tell the compiler that is the end of a statment. Forgetting to do this is a very common mistake.
The return 0; statment tells the compiler the the main function (we defined this one in the int main() line) is done, soo this means that the program has ended, hopefully succesful
As you will have noticed, the main function has been "embrassed" in brachets like these { } braces which limit the function to this area only...
Ok... that wasn't that hard... right?
As we have seen the \n code is newline but we can have even more fun with these commands:
\n Newline. Position the screen cursor to the beginning of the next line. \t Horizontal Tab. Moves the cursor to the next tab stop. \r Carriage return. Position the screen cursor to the beginning of the current line; does not advance to the next line. \a Alert. Sounds the system bell. \\ Backslash. Might be helpful to be able to print the backslash character. \" Double Quote. Prints the double qoute character.
Lets have even more fun, shall we?
Lets make our very first real program... Whoa
Code:
// Lets add up
#include <iosteam>

int main()
{
int integer1, integer2, sum; // We declare our variables

std::cout << "Please enter first integer\n"; // prompt for integer1
std::cin >> integer1; // user input for integer1
std::cout << "Please enter second integer\n"; // prompt for integer2
std::cin >> integer2; // user input for integer2
sum = integer1 + integer2; // we define sum
std::cout << "The sum is: " << sum << std::endl; // print sum

return 0; // succesful end of program
}
... that concludes our learning for this week..
Homework for next time.. modify the lets add up program to multiply the two integers.
it might be helpful to know that:
Code:
real world => C++

addition +
subtraction -
multiplication *
division /
modulus %