If the file is called iomanip, then you must use
#include <iomanip>
not
#include <iomanip.h>
cin, cout and friends are part of the C++ standard library. However, they live inside something called a namespace, which is basically a way of seperating and partitioning functions and such so that they do not interfere with each other.
For example, let's say that I decide that I want to use a variable called cout, as well as using the cout you're familar with, for output. The compiler would be confused, because it has no way of knowing which cout I want to use where. Namespaces provide a solution to this problem, by forcing you to append a string called a namespace at the beginning of functions and variables that exist in another namespace.
That might be rather confusing, so here's an example:
Code:
#include <iostream>
int
main (int argc, char **)
{
int cout = 3;
std::cout << "cout = " << cout << std::endl;
return 0;
}
Notice how I appended std:: to both cout and endl. I did that because they both exist in the namespace called std. This allows my integer variable, cout, to coexist with the cout of the C++ standard library. So, in order to use a function or a variable from another namespace, you must append the name of the namespace and two colons to the name of whatever your trying to access.
If you're lazy, you can use a so-called using directive to remove the need to give the namespace, but only for one namespace at a time. For example, this is one way of writing the Hello World program:
Code:
#include <iostream>
using namespace std;
int
main (int argc, char **argv)
{
cout << "Hello world!" << endl;
return 0;
}
This time, I didn't need the std:: in front of cout, because I already told to compiler to look in the std namespace, using the line:
using namespace std;
Personally, I feel that using directives defeat the whole purpose of namespaces and shouldn't be used much. But that's just me...