This is a simple introduction to c++, It wont teach you much but can be used to see if this is the programming lanuage you want to learn. The first requirement for learning c++ is a good bunch of spare time C++ ain't easy, so you have to use some time to learn it.
1. IDE
The first thing you should get is a IDE (Integrated development eviroment). IDE is a software where you will write your code a compile it. I use Bloodshed Dev C++. I finde this IDEgreat, and it contains everything a newbee needs.
DOWNLOAD LINK-
Bloodshed Software - Dev-C++
Download and install
1. Get started
The next thing you should do is to make a folder on one of your harddrives to save all your Projects and c++ files. I use c:\cpp . Thats the best place to save your files (my opinion). They will then be easy to access. Now go to your start menue and open cmd.exe (run>cmd.exe). When the black windows opens the type : «cd c:\cpp» (replace c:\cpp with your c++ folder) then leave it open.
3.Your first program
This program is usless, but its allways fun makeing something. Open Dev c++ click on New>Sourc File.
Now type the following:
Save as Practise_sample1.cppCode:/*Pratice_Sample1 this program wil print «I love C++!» */ #include <iostream> using namespace std; int main () { cout <<"I love C++!"; return 0; }
then press compile (ctrl+F9)
go to the blackbox from step2 and type: practise_sample1.exe. The program will then run!
Congratulations! You have just made your first c++ program, Now it's time to explain some things
The first 3 lines of the code is just a comment, the compiler ignores it, so it wont affect your program.
To make a comment you can use the command «//» or «/* /» in Dev C++ comment will appear in blue text. «//» is used for comments thats just uses 1 line «/* */» is used when the comments uses more than one line.
The comment don't need to first in the program and can be placed before or after a statement.
Example:
cout <<"I love C++!"; //this is a comment!
The next line of code is really importaint for your program, If you thought the word «include»
is there becausee it's inclueds something, then your right. The «#include <iostream>» includes the iostream libary, the compiler then includes code from the «iostream» libary. the letters io in iostream refer to input-output, which is a computer term that describes how data is input into our programs and how we get information out of them. If we fail to include the iostream file in our program, we wouldn’t be able to display the words ‘I Love C++’ on our computer monitors.
The next line contains a «{« It shows that here, the next section of code starts and all programs ends with a «}» that shows that here the code ends.
Now for the main thing in this program, «cout <<"I love C++!";» this is where we tell the compiler what to print out. «cout<<» tells the compiler that it's output, «cout<<» The .exe will the print the text thats between the quotes «"I love C++!"». Each line of code has to be ended with « ; «.
return 0; tells the program that now this section of code is over an the program will now quit. If you have several different of code section in the main c++ file then don't it's not needed. It is only needed at end of programs or after errors.
I have not included 2 lines of code in the little description of c++.
using namespace sdt;
and
int main ()
The reason for not including this is that they arn't worth focusing on at start, it may get a bit too conffusing then, thats something you will need later. This little guid will as said not teach you c++, but gives some pictures of how it verry basacly works. C++ is prettey hard to learn and is going to take a long time to master, for many people it may be best to start with easier languages as maybe Java, I would stay clear of VB since it's theaches lot's of bad habits.
But anyways, the next step of learning more c++ would be to get a book about it. Learning c++ from webased torturials ain't going to bring you far, buy a book or download a .pdf.
Personaly I have read «Learning to program with c++» by John Smiley, I find this book to start at a basic level thats good for learning it, It also dosen't requires any experience from programing from before!
Hope this helps some of the newby programmers!