The way I was taught C++ looks like this...
But after reading the first couple or chapters in a book I have purchased, I noticed that their method is slightly different...Code:#include <iostream> using namespace std; int main() { cout<<"Hello World!"<<endl; //or you could use this to start a new line... cout<<"Hello World!\n"; system("pause"); }//end main
i.e.
What I'm wondering is, is it bad habit to use 'using namespace std;' in place of always typing out that extra 'std::'?Code:#include <iostream> int main() { std::cout << "Hello World\n"; return 0; }//end main
I find that it's faster, but I really want to learn the right way. Also, are the spaces between std::cout, the insertion operator (<<) and the text ("Hello World") important? Or are the optional? I can see them as being a way to make the code more reader friendly, but I don't understand why else they would be needed.
Thanks for the help...