Loop pattern

Assume that the class of template A is defined as follows:

template <typename T>
class A
{
    B<T> b;
};

Suppose the class of template B is defined as follows:

template <typename T>
class B
{
    A<T> a;
};

Ideally, these classes will be defined in separate headers with embedded implementations. However, this will cause a cyclic inclusion problem. One solution is to include the implementation of the template classes in the cpp file. However, this will require specialized instances of the templates.

Is there a way to keep the implementation of the inlined classes and avoid the cyclic inclusion dependency? I would like to avoid using pointers if possible.

Thank,

Sam

+3
source share

All Articles