PDA

View Full Version : Is there a circular reference here?



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

I have these files:

BaseDecoder.h
YDecoder.h
Decoder.h
Decoder.cpp

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.

axeljaeger
22nd January 2006, 10:13
We need source.

jacek
22nd January 2006, 14: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.

rh
22nd January 2006, 22:51
@jacek:

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.