type into a text editor
Code:
#include <iostream>
using namespace std;
int main()
{
std::cout << "Hello World\n";
}
and save the file as hello.cpp
Now at the command line, in the same directory, type:
g++ hello.cpp -o hello
There should be no output and an executable file called hello should be generated.
run it by typing ./hello and marvel at your creation
Quote:
to be more specific "the c++ programming language " by the creator of c++
|
I don't want to discourage you and this is an excellent book that every c++ programmer should either own or have access to BUT is not the best book for learning from.
Personally I recommend "The Complete Idiots Guide to C++" by Paul Snaith for teaching you the basics and ask away here for any issues with actually compiling source code.
The was a thread just recently discussing free on-line books and tutorials too.
http://www.linuxquestions.org/questi...hreadid=230368
http://www.linuxquestions.org/questi...hreadid=230176
Essentially:
g++ sourcefile1.cpp sourcefile2.cpp -o program_name
plus switches for use later (dont use the < and > though!):
-o <program_name> used above, specifies the output file, small letter 'o'
-Wall to turn all warnings on to help you find mistakes
-g to turn debugging info on to help you debug your programs
-O<n> with n = optimization level, capital letter 'O'
-I<some_directory> to specify a directory to find include files, capital 'I' (i)
-L<some_directory> to specify a directory containing libraries
-l<some_library> to specify a library, small letter 'l' (L)
(If you don't fully understand, you will later)
Remember these are gcc specific, other compilers vary.
Good luck!