Here the hook functions themselves need to check the typeid of a data member that also belongs to hierarchy of classes. So I define a template method for that hierarchy of classes. This is the mess I run into:
void Person::leave() {
    // code
    hook();  // private virtual 
    // code
}
void Girl::hook() {  // Girl is a derived class of Person, with data member location 
                 // of type Location which itself has a derived class House
    // code
    location.locationHook(this);// what happens here depends on what kind of location she is in
    // code
}
void Location::locationHook(Person* person) {
    // Oh oh!  This depends on what class person is
}
void House::locationHook(Person* person) {
    // Oh oh!  This depends on what class person is
}
So for this situation, I have to resort to my original method of using typeid(*person) and dynamic_cast and if-statements for each type of Person derived class to define the virtual locationHook's, right?
                        
This is the solution I came up with. I tested that it works, but I don't know if it gets any approval or not (or if it will always work):