The other objects has a list of pointer to objects like the main, the main objects tell the other its addres and the object deletes it from its list
I want a objects destructor to call a method of another object to delete its pointer to me. Its in C++?
Here's a brief, overly simple example of that using cars and garages. The Car's destructor removes itself from the garage.
class car
{
~car() { myGarage-%26gt;deleteCar(this); }
Garage* myGarage;
}
class Garage
{
public:
list%26lt;Car*%26gt; myCars;
void deleteCar(Car* carToDelete) { myCars.remove(carToDelete); }
}
survey monkey
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment