g++ doesn't find #include <iostream>, but <iostream

Need help with C, C++, perl, python, etc?

g++ doesn't find #include <iostream>, but <iostream

Postby jnor » 2007-02-27 09:47

What is wrong here?

#include <iostream>

int main(){
cout<<"Hello World"<<endl;
return 0;
}

doesn't work. With

#include <iostream.h>

it works with g++ complaining about the antique header, which should be replaced by <iostream>
g++ is version 4.1.2 from debian testing.
jnor
 
Posts: 5
Joined: 2007-01-14 17:34

Postby jnor » 2007-02-27 09:56

Found solution, for future searches, since this was never a topic here:
http://www.cs.odu.edu/~zeil/cs361/Lectures-f02/00faq/faq/backwardsHeaders.html

short version:
iostream.h is the one used for backwards compatibility,
C++ programmers should now use std::cout<<"Hello World"; in the code when using <iostream> or using namespace std; before the cout.
jnor
 
Posts: 5
Joined: 2007-01-14 17:34

Postby Optional » 2007-03-01 05:01

I'm willing to bet that namespaces are one of the real reasons people avoid C++ for serious stuff (operating systems, device drivers, etc.)

:lol:
User avatar
Optional
 
Posts: 349
Joined: 2007-02-05 05:02


Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable