very quick question, let’s say I have a template:
template <class T>
class foo {
private:
T SubFoo;
...
};
And then I have things like:
foo < foo < int > > myFoo;
which works fine. In this case, myFoo would have a member called myFoo.SubFoo which would have the type foo < int >.
I would like to have a pointer in myFoo.SubFoo that points to myFoo. I don’t know how to properly call this, a class-member pointer of SubFoo that points to the whole mother class, myFoo. Is this possible? I tried to include the declaration:
template <class T>
class foo {
private:
...
T SubFoo;
foo< foo < T > >* p2mother;
...
};
But this does not seem to work.
In general, what I am doing is setting up a recursive structure. It’s quite easy to pass communication down the recursion but I am finding trouble going “upwards”. Maybe I am designing this wrongly in the first place.
Thanks a lot!
The more general case (this works in g++):