Requirements:
First off you will need C++ get it >
HERE<.
A brain and basic computer knowledge.
What you will learn (Updated Version 1):
*Making your first C++ program
* Fundamental Commands/Instructions/Keywords
* Custom made Commands/Instructions...
* .cpp .c / .hpp .h files (source/header)
* Including headers in source files
* Using stuff from header files
* Functions
* The c++ main function
Lets get started:
When you open Visual C++ 2008 Express Edition or whatever version of C++
click "new project" then you should get this:
[IMG]http://i359.photobucke*****m/albums/oo32/pictureaddict/untitled-8.jpg[/IMG]
Now for this tutorial we want to click this:
[IMG]http://i359.photobucke*****m/albums/oo32/pictureaddict/part1.jpg[/IMG]
now we want to name it "tutorial 1".
You should get this:
[IMG]http://i359.photobucke*****m/albums/oo32/pictureaddict/untitleds.jpg[/IMG]
Now we want to click [IMG]http://i359.photobucke*****m/albums/oo32/pictureaddict/finish.jpg[/IMG] since all the settings we need are already done.
If all was done right you should something like this:
[IMG]http://i359.photobucke*****m/albums/oo32/pictureaddict/finally.jpg[/IMG]
Q: what is a project?
A:neat way of storing all the files and options and settings together in one folder so that when were ready to compile are project everything is neatly stored in a neat place where we can find them and the compiler can find them and where everything will be compiled and are .exe program will be ready.
Q: what is a file that ends with .cpp?
A: any file with .cpp at the end, is that file that is gonna get compiled by the compiler. CPP stands for "C++" which obviously means the file contains C++ code.
Now time to get to the coding:
open "tutorial 1" in C++ and erase everything so we can start from scratch.
this will be are first line of code:
Code:
#include "stdafx.h"
now any code in blue is a keyword which are the main basic words which are the commands of this programming lang. what the
#include is doing is "wait, dont go any further yet, please go ahead and open of this file which is in the quotes "" or triangular brackets and read everything thats there and compile all that stuff first and then continue with the rest of the .cpp file code.
now are second line of code:
Code:
#include <iostream>
now we are using brackets because quotes "" are local file which is in are project, and brackets are telling it it's in a place it should know, because its already set in the compiler settings. now red code is usually the headers, code already made by programmers.
now are third line of code:
Code:
Code:
using namespace std;
now were telling the program we are going to use a package "std" and asking permission to use the package.
now are fourth line of code:
what we are doing is creating a function and we named it main
are fifth line of code:
this is a opening brace function
are six line of code:
Code:
cout << "Hello World!";
"cout" is a basic word, its not a main C++ keywords, and is located in <iostream> and the triangular brackets are required when using "cout" and since we wanted to display text the way we display text is we enclose it inside quotes. then we have the semi colan, most keywords in C++ must end with a semi colon.
are seventh line of code:
all this really is doing is telling the program to wait til you push enter
are eight line of code:
all this is doing is telling the compiler the code is done, stop this function and go back to whatever was happening before. Also something to keep in mind is C++ is CASE SENSITIVE. so if you type anything in this code in cap it will give you a error because it wasnt told what for say Cin.get(); in was.
are ninth line of code:
this is a closing brace function.
finalized product:
Code:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!";
cin.get();
return 0;
}
to test this and see your first C++ program click this [IMG]http://i359.photobucke*****m/albums/oo32/pictureaddict/untitled-9.jpg[/IMG]
and congrats
hope you learned something
good day.
If you have any questions go ahead and PM me, I am more then happy to answer questions or problems etc.
[IMG]http://i359.photobucke*****m/albums/oo32/pictureaddict/bxrsig.jpg[/IMG]
[IMG]http://i359.photobucke*****m/albums/oo32/pictureaddict/ghostrecont.jpg[/IMG]