Post: Ultimate C++ Guide (Still In Progress)
03-10-2011, 09:24 AM #1
oman
Banned
(adsbygoogle = window.adsbygoogle || []).push({}); I am writing this guide to try and help people who are starting off with learning C++ programming I will avoid going into too much detail so that even people

with no prior experience can understand this
Although this guide is mainly aimed at new users of C++ like myself it is also useful for those who need a little update on the new features the language

has acquired from the latest standards.

The program I will be using is You must login or register to view this content. but this should work on any C++ Compiler

All Of The Tutorials In This Guide Will Be For "Console Applications" Most (If Not All) Compilers Support This.
If you are using Code::Blocks do this to start a console application
1. Open Code::Blocks (you might need to select a compiler just chose the default one)
2. Select "Create A New Project"
3. Select "Console Application"
4. Select "C++" And Hit Next
5. Select A Project Title And A Folder To Create It In And Hit Next
6. Just Hit "Finish" At This Screen
7. On The Left Of The Screen Open The "Sources" Branch And Then Open "Main.CCP"
8. And Delete Everything In There
9. This Is Where You Will Write Your Code

LOG
08-03-11 09.30 – I started to this guide
10-03-11 09.25 - Finished Hello World Program And Published To NGU
19-03-11 19.05 - Added Quiz Page And Question 1

[multipage=Basics/Structure Of A Program]
The best way to start learning a programming language is probably to actually write a program (I advise actually typing out each of these individual lines

rather than copy and pasting them) and guess what program we will be writing YEP your right it’s the “Hello World” one

Line 1.
Originally posted by another user
#include< iostream>

lines that begin with the # sign are not regular code lines with expressions but are indications for the compilers pre-processor the line “#include<iostream.” tells the pre-processor to include the iostream standard file. This specific file (iostream) includes the declarations of the basic standard input/output library in C++

Line 2.
Originally posted by another user
using namespace std;

All the elements of the standard C++ library are declared within what is called a namespace. This line is very frequent in C++ programs that use the standard library

Line 3.
Originally posted by another user
int main ()

This line corresponds to the beginning of the definition of the main function. The main function is the point by where all C++ programs start their execution, independently of its location within the source code. It does not matter whether there are other functions with other names defined before or after it - the instructions contained within this function's definition will always be the first ones to be executed in any C++ program. For that same reason, it is essential that all C++ programs have a main function.

The Next Set Of Lines MUST Be Included In Braces ({}) You Will Get A Better Idea Of What I Mean When We Have The Program Written Out In Full

Line 4.
Originally posted by another user
cout << "Hello world!";

This line is a C++ statement. A statement is a simple or compound expression that can actually produce some effect. In fact, this statement performs the only action that generates a visible effect in our first program cout is the name of the standard output stream in C++, and the meaning of the entire statement is to insert a sequence of characters (in this case the Hello World sequence of characters) into the standard output stream.

Line 5.
Originally posted by another user
cin.ignore();

I had to add this line myself and this line will stop your program ending automatically when you launch your .exe with some compilers this is not needed but with mine it is all it does is basically require you to hit enter before ending the program

Line 5(Alternative).
Originally posted by another user
cin.get();
This line is basically an alternative way to stop the program ending itself automatically.

Line 6(Optional).
Originally posted by another user
// This is My First C++ Program

line's beginning with a "//" are known as comment line's and are not read by the compiler but are very useful in large programs

If you write all of this out you will end up with a program like this
Originally posted by another user
#include <iostream>

using namespace std;

int main()
{
cout << "Hello world!";
cin.get();
// This is My First C++ Program
}


Build and run your program
Press "F9" in Code::Blocks

Other possible layouts for the same program
In C++ the same type of program can be written in many different ways bellow are a few other choices
Originally posted by another user
#include <iostream> using namespace std; int main() { cout << "Hello world!"; cin.get(); // This is My First C++ Program}

this layout is VERY unorganised but it is the EXACT same as the others just all on 1 line

Originally posted by another user
// This is My First C++ Program
#include <iostream>

using namespace std;

int main()
{
cout << "Hello world!";
cin.get();
}

because the comment line's aren't read by the compiler it doesn't matter where they go in the program

[Multipage=Quiz]
on this page I will put up some questions who ever answers the questions via private message will get + (or - if they want) rep please only answer via private message so the answer isn't given away

Q1. What is missing from this piece of C++ code
Question Posted On: 19-03-11 19.05
Question Answered On: N/A
1st Answered By: N/A
Hint
Its near the end of the code
Originally posted by another user
#include <iostream> using namespace std; int main() { cout << "Hello world!"; cin.get(); // This is My First C++ Program
(adsbygoogle = window.adsbygoogle || []).push({});

The following 3 users say thank you to oman for this useful post:

dex2grigg, Huseyboy, Solid Snake
03-10-2011, 03:09 PM #2
Kombust
At least I can fight
Looks great so far =D
Please can you explain to me what C++ is and what it can be used for since i've only heard that it's similar to Visual Basic
03-10-2011, 05:55 PM #3
x-MaGiiKZz-o
Who’s Jim Erased?
Originally posted by Troll View Post
Looks great so far =D
Please can you explain to me what C++ is and what it can be used for since i've only heard that it's similar to Visual Basic


C++ is a scripting language that enables you to create programmes, simple to complex. It's very handy and lot's of big companies include C++ coding in some of they're software.

By the way, looking good so far with the tutorial. Winky Winky
03-10-2011, 07:24 PM #4
oman
Banned
Originally posted by Troll View Post
Looks great so far =D
Please can you explain to me what C++ is and what it can be used for since i've only heard that it's similar to Visual Basic


thanks and yeah x-MaGiiKZz-o has already explained what C++ is

Originally posted by o View Post
C++ is a scripting language that enables you to create programmes, simple to complex. It's very handy and lot's of big companies include C++ coding in some of they're software.

By the way, looking good so far with the tutorial. Winky Winky


Thanks and thanks for answering his question (No Sarcasam intented)

Who can answer my 1st Quiz question first
+ (or -) rep for everyone who answers correctly
03-11-2011, 02:28 AM #5
Originally posted by Davidson92 View Post
I am writing this guide to try and help people who are starting off with learning C++ programming I will avoid going into too much detail so that even people

with no prior experience can understand this
Although this guide is mainly aimed at new users of C++ like myself it is also useful for those who need a little update on the new features the language

has acquired from the latest standards.

The program I will be using is You must login or register to view this content. but this should work on any C++ Compiler

All Of The Tutorials In This Guide Will Be For "Console Applications" Most (If Not All) Compilers Support This.
If you are using Code::Blocks do this to start a console application
1. Open Code::Blocks (you might need to select a compiler just chose the default one)
2. Select "Create A New Project"
3. Select "Console Application"
4. Select "C++" And Hit Next
5. Select A Project Title And A Folder To Create It In And Hit Next
6. Just Hit "Finish" At This Screen
7. On The Left Of The Screen Open The "Sources" Branch And Then Open "Main.CCP"
8. And Delete Everything In There
9. This Is Where You Will Write Your Code

LOG
08-03-11 09.30 – I started to this guide
10-03-11 09.25 - Finished Hello World Program And Published To NGU
19-03-11 19.05 - Added Quiz Page And Question 1

[multipage=Basics/Structure Of A Program]
The best way to start learning a programming language is probably to actually write a program (I advise actually typing out each of these individual lines

rather than copy and pasting them) and guess what program we will be writing YEP your right it’s the “Hello World” one

Line 1.
lines that begin with the # sign are not regular code lines with expressions but are indications for the compilers pre-processor the line “#include<iostream.” tells the pre-processor to include the iostream standard file. This specific file (iostream) includes the declarations of the basic standard input/output library in C++

Line 2.
All the elements of the standard C++ library are declared within what is called a namespace. This line is very frequent in C++ programs that use the standard library

Line 3.
This line corresponds to the beginning of the definition of the main function. The main function is the point by where all C++ programs start their execution, independently of its location within the source code. It does not matter whether there are other functions with other names defined before or after it - the instructions contained within this function's definition will always be the first ones to be executed in any C++ program. For that same reason, it is essential that all C++ programs have a main function.

The Next Set Of Lines MUST Be Included In Braces ({}) You Will Get A Better Idea Of What I Mean When We Have The Program Written Out In Full

Line 4.
This line is a C++ statement. A statement is a simple or compound expression that can actually produce some effect. In fact, this statement performs the only action that generates a visible effect in our first program cout is the name of the standard output stream in C++, and the meaning of the entire statement is to insert a sequence of characters (in this case the Hello World sequence of characters) into the standard output stream.

Line 5.
I had to add this line myself and this line will stop your program ending automatically when you launch your .exe with some compilers this is not needed but with mine it is all it does is basically require you to hit enter before ending the program

Line 5(Alternative). This line is basically an alternative way to stop the program ending itself automatically.

Line 6(Optional).
line's beginning with a "//" are known as comment line's and are not read by the compiler but are very useful in large programs

If you write all of this out you will end up with a program like this


Build and run your program
Press "F9" in Code::Blocks

Other possible layouts for the same program
In C++ the same type of program can be written in many different ways bellow are a few other choices

this layout is VERY unorganised but it is the EXACT same as the others just all on 1 line


because the comment line's aren't read by the compiler it doesn't matter where they go in the program

[Multipage=Quiz]
on this page I will put up some questions who ever answers the questions via private message will get + (or - if they want) rep please only answer via private message so the answer isn't given away

Q1. What is missing from this piece of C++ code
Question Posted On: 19-03-11 19.05
Question Answered On: N/A
1st Answered By: N/A
Hint
Its near the end of the code


would you like some books for this to help out just pm me a request and i will get it for you im sure full books would help out a lot

---------- Post added at 09:28 PM ---------- Previous post was at 09:27 PM ----------

Originally posted by Davidson92 View Post


rd C++ library are declared within what is called a namespace. This line is very frequent in C++ programs that use the standard library

Line 3.
This line corresponds to the beginning of the definition of the main function. The main function is the point by where all C++ programs start their execution, independently of its location within the source code. It does not matter whether there are other functions with other names defined before or after it - the instructions contained within this function's definition will always be the first ones to be executed in any C++ program. For that same reason, it is essential that all C++ programs have a main function.

The Next Set Of Lines MUST Be Included In Braces ({}) You Will Get A Better Idea Of What I Mean When We Have The Program Written Out In Full

Line 4.
This line is a C++ statement. A statement is a simple or compound expression that can actually produce some effect. In fact, this statement performs the only action that generates a visible effect in our first program cout is the name of the standard output stream in C++, and the meaning of the entire statement is to insert a sequence of characters (in this case the Hello World sequence of characters) into the standard output stream.



If you write all of this out you will end up with a program like this


Build and run your program
Press "F9" in Code::Blocks

Other possible layouts for the same program
In C++ the same type of program can be written in many different ways bellow are a few other choices

this layout is VERY unorganised but it is the EXACT same as the others just all on 1 line


because the comment line's aren't read by the compiler it doesn't matter where they go in the program



would you like some books for this to help out just pm me a request and i will get it for you im sure full books would help out a lot
03-11-2011, 10:16 AM #6
oman
Banned
Originally posted by XMlssy View Post
would you like some books for this to help out just pm me a request and i will get it for you im sure full books would help out a lot

---------- Post added at 09:28 PM ---------- Previous post was at 09:27 PM ----------



would you like some books for this to help out just pm me a request and i will get it for you im sure full books would help out a lot


it doesnt matter i got alot of books for it myself but i've got alot of uni stuff to do so wont be able to finish it for now
03-11-2011, 02:04 PM #7
Cody_h4x
Nobody is like me
Veyr good post alot of noob's still don't know how this works:p
Great post :y:
03-11-2011, 02:41 PM #8
sweet. i can learn c++ now. thx man

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo