Internal typedef and circular dependency
- by bcr
I have two classes whose functions take typedefed pointers to eachother as return values and parameters. I.e.:
class Segment;
class Location : public Fwk::NamedInterface {
public:
// ===== Class Typedefs =====
typedef Fwk::Ptr<Location const> PtrConst;
typedef Fwk::Ptr<Location> Ptr;
// ===== Class Typedefs End =====
void segmentIs(Segment::Ptr seg);
/* ... */
}
and
class Location;
class Segment : public Fwk::NamedInterface {
public:
// ===== Class Typedefs =====
typedef Fwk::Ptr<Segment const> PtrConst;
typedef Fwk::Ptr<Segment> Ptr;
// ===== Class Typedefs End =====
void locationIs(Location::Ptr seg);
/* ... */
}
This understandably generated linker errors...which the forward declarations of the respective classes don't fix. How can I forward declare the Ptr and PtrConst typedefs while keeping these typedefs internal to the class (i.e. I would like to write Location::Ptr to refer to the location pointer type)?
Thanks folks!