Re: [SLE] C++ and ld issues
J.Drews <j.e.drews@worldnet.att.net> writes:
On Sunday 30 September 2001 06:04 pm, you wrote:
#include <iostream>
int main() { cout << "Hello World\n";
return 0; }
Oops:
gcc -o test test.C
This should be:
g++ -o test test.C
This answer solves the problem on SuSE 7.2 with gcc-2.95.3. But note that the program is not correct according to the ISO C++ standard and will not compile with gcc-3.0.1. Use: #include <iostream> using namespace std; int main() { cout << "Hello World\n"; return 0; } or (for backward compatibility) #include <iostream.h> int main() { cout << "Hello World\n"; return 0; } -- Alexandr.Malusek@imv.liu.se
* Alexandr Malusek [01 Oct 2001 10:38:36 +0200]: [yes, I know this is off topic]
#include <iostream> using namespace std;
My only comment would be to never ever do this. This pulls everything into the global namespace and simply defeats all that namespaces were meant for. If you must, only do that for selected parts. IMNSHO, one should right away get used to the namespaces and write it as #include <iostream> int main (int argc, char **argv) { std::cout << "Hello World\n"; return 0; } -- Penguins to save the dinosaurs -- Handelsblatt on Linux for S/390
participants (2)
-
Alexandr Malusek
-
philippt@t-online.de