View Full Version : Is there a circular reference here?

22nd January 2006, 06:06
I have exempted actual code for the sake of simplification, so this is basically how it goes:

I have these files:


BaseDecoder.h declares an abstract BaseDecoder class.

YDecoder.h declares a YDecoder class derrived from BaseDecoder and includes BaseDecoder.h.

Decoder.h declares a Decoder class (not inherited from anything) which contains a member of type BaseDecoder (and other misc. methods), and includes BaseDecoder.h.

Decoder.cpp implements Decoder class member methods such as getFileName and setDecoder and includes Decoder.h and YDecoder.h.

The error that i'm getting is:
cannot declare member function `Decoder::getFileName' within `YDecoder'

getFileName is declared in Decoder.h, not in YDecoder, yet gcc somehow thinks it is.

I've tried some forward declarations of the BaseDecoder class in Decoder.h and YDecoder.h, but that just creates different errors.

Thanks to any suggestions.

22nd January 2006, 09:13
We need source.

22nd January 2006, 13:20
The error that i'm getting is:
cannot declare member function `Decoder::getFileName' within `YDecoder'
In which file and which line does this error occur? Check if you have semicolons after all class definitions.

22nd January 2006, 21:51

Good suggestion. It was actually an implementation detail i was going to put in the header, but changed my mind and inadvertently left an opening brace.

It threw me off because the error for that only appears later down in the output window. As probably most people do, i only pay attention to the first errors listed since they typically cause whatever else is broken down the line.

Thanks again.