I'm having trouble compiling an application(VC++2008). I'm getting the undefined type error in one of my classes.
I have two files channel.h and link.h:
// channel.h
class Channel {
private:
bool marked;
...
public:
...
void mark(void) { marked = true; }
void unmark(void) { marked = false; }
bool is_marked(void) const { return marked; }
...
};
And link.h
// link.h
#include "nodes.h" // <= includes "channel.h"
class Channel;
class Link {
protected:
Channel *src, *dst;
...
public:
...
void mark_src(void) { src->mark(); } //<= error C2027: use of undefined type 'Channel'
void unmark_src(void) { src->unmark(); } // <= error C2227: left of '->mark' must point to class/struct type
bool is_marked_src(void) const { return src->is_marked(); }
void mark_dst(void) { dst->mark(); }
void unmark_dst(void) { dst->unmark(); }
bool is_marked_dst(void) const { return dst->is_marked(); }
...
};
I have include guards in every header file(each header file is named differently). I know this means that the compiler does not know the type 'Channel' at compile time but is there a way not to merge the files channel.h and link.h together? I don't want the implementation of the mark methods in the same .cpp file either.
Many thanks in advance.
Sebi

New Topic/Question
Reply



MultiQuote





|