Kevin Goodsell <us*********************@neverbox.com> writes:
Ensoul Chee wrote:
I used
#include <iostream.h>
int m;
cout << "Hexadecimal == 0x" << hex << m << endl;
to print value of m in hexadecimal mode. But I got the compile error
like this
couttest.cpp:20 `hex' undeclared (first use this function)
What's wrong with the code?
OS: Redhat 9
Compiler: gcc 3.2.2
In addition to the other replies, std::hex is technically presented in
<ios>. <ios> is probably #included in <iostream>, but I don't know if
this is required.
It's not. <iostream> requires several things from <ios>, but AFAIK,
it doesn't require the manipulators. So you can't rely on them
being provided by <iostream> . Really, all <iostream> provides is
cin, clog, cerr, cout, and their wide character equivalents. Lots
of other stuff comes long just becuase those objects have complex
types, which require many things, but not the manipulators.