Possible Duplicate:
Forward declare FILE *
Suppose I want to write a wrapper class for C struct that is accest by a pointer to it such as FILE
in C you have to say
typedef struct _iobuf
{
/*content of this struct*/
} FILE;
to get rid of the struct in object declarations. Now I want to do the following in filec.h:
class FILE;
class FileC
{
public:
FileC(const char* name,const char* mode);
~FileC();
private:
FILE* fptr;
};
And in filec.cpp:
#include "filec.h"
#include <cstdio>
//Implementation of FileC member functions
But when compiling I just get complaints about incomplete type struct FILE. Switching include order give that FILE already has been declared. I can solve it by using implementation specific details or use a void* instead FILE* casting back and forth. But how to do it nicely? Using iostream is not an answer because it also includes stdio anyway.