I'm having trouble with a circular reference of types. For an implmentation of the following:
// Parent.h
template <typename OtherType>
class EnclosingType
{
public:
typename OtherType type_;
};
class OtherType
{
public:
EnclosingType & e_;
OtherType (EnclosingType & e) : e_(e) {}
};
The requirement is that OtherType take a reference to an object of EnclosingType so that it can invoke methods on EnclosingType, and EnclosingType can invoke methods on OtherType. The main goal is to allow implementers to supply their own OtherType-derived types.
What is the best way to handle the case where this type of circular dependency exists ? What is the proper declaration of OtherType ? What is the proper declaration of OtherType::EnclosingType ? What is the proper declaration of Enclosing::OtherType::type_ ? Is what I need to do even possible ?
Thanks.