I ran into the following problem:
class School
{
Manager manager;
}
class Manager
{
School school;
}
It will require infinite memory, and will cause unnecessary infinite loop.
What is the best way to solve it?
I ran into the following problem:
class School
{
Manager manager;
}
class Manager
{
School school;
}
It will require infinite memory, and will cause unnecessary infinite loop.
What is the best way to solve it?
class School;
class Manager
{
std::weak_ptr<School> school;
};
class School
{
std::shared_ptr<Manager> manager;
};
Depending on what you want to do, you might want to use the shared_ptr in Manager and the weak_ptr in School instead but the concept stays the same.