Soo.....
If you want to learn the basics of C++ you are in the right place.
But keep in mind that this is a short intense course!
Requirements:
-IDE(prefered Microsoft Visual C++ 2010 (Express(free)))
-A brain
Keep in mind that this is a crash course. Won't explain it the long way and it can be hard to understand some time.
-----------------------------------------------------------------------------------------------
1. Getting know with the Integrated Development Environment
If you are launching Microsoft Visual C++ (will say MSVC++ instead) the first time you are getting this screen:
To create a project file for our purpose you have to File -> New -> Project...
Here you have to Search for "Win32 Console Appplication". Also you can name the Project in this Screen.
After that an Application Wizard pops up. Press Next > and check the box for "Empty project" !!!
Congratulation you just created your first project. But it doesn't have any Files in it.
Let's add some then
We'll add a C++ File so select it and name it what you want. I'll call it main.
Let's create our first programm!
This programm is just printing "Hello ItsMods.com" into the console.
Why does we need to much code to do this?
First you have to know that lines that are beginning with // are comments. So you can write something after a // and it will be ignored by the compiler
also you can write comments over X lines with /* */ like this:
So comments are clear now. Next special character is the # in the first line.
# signals the compiler that something has to be done in this case #include the compiler is adding a file into this file. "iostream" is a file that comes with MSVC++.
Now int main()
It is a function that returns an integer value. EVERY PROGRAMM BEGINS TO START AT THE main-function.
return 0; is saying that in this line the function will return the integer value "0".
Function "cout":
cout stands for ©onsole (out). It is printing something on the console. To print soemthing you have to write the operator << before it.(Why? Just do it for now. Operator comes at a later chapter). The Character-String "Hello ItsMods.com\n" was printed in this program.
You can write somthing like this:
or
Both will do the same
But what was this "\n" doing in the programm?
This Strings are called "Escape-Sequence". These are special strings that are recognized by the function cout.
A table can be found at the german Wikipedia(couldn't find the english one):
http://de.wikipedia.org/wiki/Escape-Sequenz
\n stans for newline which is equivalent to the return-key on your Keyboard.
Soo now you have an IDE, Project and a sourcefile. But it isn't still a programm. You have to Compile and Link it.
With MSVC++ it is easy to do that. Just press at the Green Triangle on the top bar.
Yes. The Window is appearing and disappearing again. Thats normal. The Program has done his job and is quitting. To prevent that you can write
before
We are discussing the normal usage of this function later.
Next to the Green Triangle there is a Dropdownmenue.
You can select between Debug, Release and configuration manager. The last item you can forget
Debug and Release...
Generally you want to keep it at Debug. It will help you when you are debugging /finding a bug in your programm. You'll need it 100% at some time because no programm is bugfree.
If you are ready with your programm and want to share it/sell it you want to build a Release build. The compiler is optimizing your code so your programm can run at the maximum speed.
-----------------------------------------------
~End of Chapter 1
Yeah. you wanted a complete basic C++ Tutorial here is the beginning.
Of course most of you guys knew the before.
- Ich1994
If you want to learn the basics of C++ you are in the right place.
But keep in mind that this is a short intense course!
Requirements:
-IDE(prefered Microsoft Visual C++ 2010 (Express(free)))
-A brain
Keep in mind that this is a crash course. Won't explain it the long way and it can be hard to understand some time.
-----------------------------------------------------------------------------------------------
1. Getting know with the Integrated Development Environment
If you are launching Microsoft Visual C++ (will say MSVC++ instead) the first time you are getting this screen:
To create a project file for our purpose you have to File -> New -> Project...
Here you have to Search for "Win32 Console Appplication". Also you can name the Project in this Screen.
After that an Application Wizard pops up. Press Next > and check the box for "Empty project" !!!
Congratulation you just created your first project. But it doesn't have any Files in it.
Let's add some then
We'll add a C++ File so select it and name it what you want. I'll call it main.
Let's create our first programm!
Code:
#include <iostream>
using namespace std;
int main()
{
//Print in console
cout<<"Hello ItsMods.com\n";
return 0;
}
This programm is just printing "Hello ItsMods.com" into the console.
Why does we need to much code to do this?
First you have to know that lines that are beginning with // are comments. So you can write something after a // and it will be ignored by the compiler
also you can write comments over X lines with /* */ like this:
Code:
//Single line comment
/* Comment
Block
8924wgfeu9g
q34rfgovheaosrgh
*/
So comments are clear now. Next special character is the # in the first line.
# signals the compiler that something has to be done in this case #include the compiler is adding a file into this file. "iostream" is a file that comes with MSVC++.
Now int main()
It is a function that returns an integer value. EVERY PROGRAMM BEGINS TO START AT THE main-function.
return 0; is saying that in this line the function will return the integer value "0".
Function "cout":
cout stands for ©onsole (out). It is printing something on the console. To print soemthing you have to write the operator << before it.(Why? Just do it for now. Operator comes at a later chapter). The Character-String "Hello ItsMods.com\n" was printed in this program.
You can write somthing like this:
Code:
cout << "Test, Test 1.2.3...\n";
Code:
cout << "Test," << "Test " << "1.2.3...\n";
But what was this "\n" doing in the programm?
This Strings are called "Escape-Sequence". These are special strings that are recognized by the function cout.
A table can be found at the german Wikipedia(couldn't find the english one):
http://de.wikipedia.org/wiki/Escape-Sequenz
\n stans for newline which is equivalent to the return-key on your Keyboard.
Soo now you have an IDE, Project and a sourcefile. But it isn't still a programm. You have to Compile and Link it.
With MSVC++ it is easy to do that. Just press at the Green Triangle on the top bar.
Yes. The Window is appearing and disappearing again. Thats normal. The Program has done his job and is quitting. To prevent that you can write
Code:
cin.get();
Code:
return 0;
Next to the Green Triangle there is a Dropdownmenue.
You can select between Debug, Release and configuration manager. The last item you can forget
Debug and Release...
Generally you want to keep it at Debug. It will help you when you are debugging /finding a bug in your programm. You'll need it 100% at some time because no programm is bugfree.
If you are ready with your programm and want to share it/sell it you want to build a Release build. The compiler is optimizing your code so your programm can run at the maximum speed.
-----------------------------------------------
~End of Chapter 1
Yeah. you wanted a complete basic C++ Tutorial here is the beginning.
Of course most of you guys knew the before.
- Ich1994