In some libraries I've seen, a lot of emphasis is put into change of ownership of pointers, like for example a class method that allocates and returns a pointer to an object while relinquishing its ownership to the caller.My question is: how would you design if you had to code something with the constraint that no pointer ownership gets transferred, ever ?
Pointer ownership tips
design;pointers
If you want to be sure that pointer ownership never gets transferred, you have to ensure that each object has an owner from your library.  This can be done in two ways.When you create your objects, the constructor should take a reference to another object that will be its owner, and then add itself to the owner's child list.You don't create the objects yourself; instead you ask the owner to create a new child, which it adds to its list.Either way, this can restrict your ability to delete objects when they're no longer needed but their parent object is.  To get around this, put a line in the destructor that removes the object being destroyed from its parent's list.