This appears similar to where I'm headed as well as this question.
Consider the following
template<typename T>
class A
{
private:
class B
{
private:
B* link;
public:
B();
~B();
};
B* head;
public:
A();
~A();
};
The above creates the structure below assuming the function to create and link each B
is declared and defined
If I perform the operation as shown above, then
B* position = head;
position = head->link;
head->link = nullptr;
delete[] head;
head = position;
I understand that calling the inner class destructor will result in the outer class destructor being called. Have I correctly handled garbage collecting the resource x
or have I done something undefined?