This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: iostream.h problem


iostream (and all ios headers, etc.) are part of the C++ STL (Standart Template Library).
Trying to link against them using gcc will not work since these are C++ headers.
g++ seems to be handeling this quite easly though... :)

BTW, in the latest STL headers, iostream.h is not used anymore.
all STL classes are encapsulated into a namespace called std.

In order to use cin and cout etc. normally, do:

// test.cpp:
#include <iostream>
using namespace std; // invoke std into the global namespace

// Compile/Link with g++, not gcc ! :]
int main()
{
cout << "Mary had a little lamb";

// if you ommit line no. 2 (using namespace std), you could write:
// std::cout << "Mary had a little lamb";
// this will work just fine.
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]