Solved using class without header file in C++

In my header file... my.h
Code:
using sql::ResultSet;

class Mysqlboard : public Board
{
protected:
   sql::ResultSet *myQuery(std::string str);
If I compile this, compiler complains "sql has not been declared".
I don't want to include the whole sql header files just to declare a pointer.
Is there any way to solve this?
Thanks in advance..

Oops. I miss-arranged header files. I included my header before sql headers. Sorry to bother you.
 
In fact it's not completely solved. I just included this header file after the sql header files. So I cannot freely include my header file anywhere I want it. If I include my header before the sql headers, then I get a compile error.
What I want is to inform the compiler that there is definition of sql::Resultset elsewhere without including the whole header file.
Because I did't use the pointer in my header, it is just a declaration.
Thanks..
 
You may use a so called forward declaration. It looks like the class definition, but has no body. In your case, I would try class sql::ResultSet;,which tells the compiler that there is such a class, but does not tell it how it will look like.
 
Back
Top