Problem with #include
In my source i include a file tat holds all the includes and
some functions and voids.
Now when my header file named "test.h" has this:
cout << "Im printing something" << endl;
And i compile it with my source, Im getting error messages
with the void in my header file that are pointing out that
"#include <iostream>" isn't even being used in the header file
I can use it in my source, but not in the header file???
What am i doing wrong?
Donīt really understand what you mean. From where I can se you are trying to compile a header file??? In c++ you cannot compile header files just source files.
you can't have code/functions in a header file, just definitions of things.
So in test.cpp you will have a function
and in test.h
cout << "something" << endl;
you just have the prototype of the print function so
(this is my header file)
cout << "bla"; // I can't do this!
printf("bla"); // But i can do this ?1
I'ts like it isnt using iostream in the functions in the header file
(im not compiling the header file, im including it in my source)
You need to have this line:
under #include <iostream>
using namespace std;
If not then each call to cout needs to read:
DOH! Of course , sorry i forgot