best place to learn c++

Associate
Joined
28 Aug 2013
Posts
382
hello
im looking to learn c++could someone please reccomend where is the best place to learn website or somewhére else maby

thank you very much
 
Associate
Joined
30 Jan 2009
Posts
34
I learned on Bloodshed, pretty basic and free. Visual Studio may be a bit overkill for a beginner, but gives better debugging tools.
 
Last edited:
Soldato
Joined
13 Feb 2003
Posts
6,157
If you want to learn programming, then learning to debug is not optional. MSVS has great debugging support so I always advocate MSVS for this reason.

reddit has an active 'cpp_questions' sub. I would advise solving whatever problem you're interested in, and then posting there and asking for a critique (or asking for help if you get stuck).
 
Soldato
Joined
17 Jun 2012
Posts
11,259
Why not learn here, I will try and help out though only a novice myself in C++ with some intermediate knowledge.

I will start off.

You need a compiler, linker and editor(or full IDE) to write C++ programs.

Generally people use Visual studio or MinGW/gcc although there is LLVM which seems to be pretty highly thought of but not as used. Visual studio 2013 & 2015 are free AFAIK, which is a pretty amazing offer although there are paid versions of VS which give you a lot of extra plugins/support which you really want to have if you get serious.

I would advise you to use VS 2015 as it's the most popular IDE/compiler and hence you will have less compatibility issues as more source is written in VS.

Once VS is set up, you can start writing some code. Start a new console app in VS which will bring up the code editor with a basic C++ program, "Hello World!". VS will create a default folder in 'username/documents/Visual Studio 2015, where all your project files are saved to. Within each project in this directory you will find a few files in the root of the folder and a bin folder which contains debug and release folders. These two last folders are where your compiled EXE/DLL will be saved too, whether you compile release or debug versions.

You then need to compile & run the program, 'run' in the toolbar of VS, and will be presented with a console window showing, you guessed it, "Hello World!". The console window will close right away(classic beginner question) unless you run the compiled EXE from the command line(cmd), which is the way it is meant to be run. To fix this add a cin.get() which waits for user input in the terminal.

Code:
#include <iostream>
using namespace std;

int main(){

cout << "Hello world!";
cin.get();

}

That's a start.
 
Associate
Joined
7 Sep 2014
Posts
1,165
The main function is an exception where the return statement can be ommited.
If you ommit the return statement in main, then an implied return 0 is used.

Oh that's interesting I've always been told it's bad practice not to have a return statement as in C you must have a return statement to the
Code:
 int main
method. Apples and pears I guess
 
Associate
Joined
2 Jun 2007
Posts
1,180
Location
Bradford
Oh that's interesting I've always been told it's bad practice not to have a return statement as in C you must have a return statement to the
Code:
 int main
method. Apples and pears I guess

Like I said the main function is an exception regarding being allowed to define a none void function and omit a return statement. This is allowed by the c++ standard.

For instance if you compile a file containing:
Code:
int main()
{
}
The code compiles and no error is generated.

If you declare/define a function other than main to return a value and omit a return statement:
Code:
int intfunc()
{
}
A compile error results:
error C4716: 'intfunc': must return a value (MS compiler).

The argument whether to omit the return statement in main (even though it is allowed by the standard) or to write it explicitly, is as old as the hills. :)

Edit: Being able to omit the return statement in main is in the C standard as well as the C++ standard.
 
Last edited:
Back
Top Bottom