Imagine I have a C++ program that operates a machine that can rearrange the biology of any animal so that it is now of a different type of animal. So a bird can become a dog, a dog can become a cat, etc.
My program stores in memory a bunch of objects of type "Animal", which represent the various animals in my possession. Derived from the "Animal" class are various classes, each one representing a different type of animal (dog, cat, etc.) Once my program causes the conversion of an animal, it must be aware of the animal's new abilities/inabilities & weaknesses. For example, if my bird is converted into a dog, "polly.canFly" should now be false. Or, "polly.fly()" should no longer be valid.
JLBorges' suggestion of using the proxy pattern really worked wonders. But the patterns introduced can get really complex, so you need to really study it and be careful (and get ready to do a lot of debugging as your program evolves).
I think I can do what I want just by dropping down to Assembly level. I was thinking of creating a function whose sole purpose is to change the address to which a pointer points.
Why not just use polymorphic behavior with an abstract base class? I don't know how exactly you want to approach this unless I see your program, but as I understand it now you can just use a base pointer and (re)cast it as needed.
The best and easy way is through polymorphism. You can define a base class as animal and then you can derive other classes like cat, dog, bird, etc. Then when you convert an object of type bird to an object of type dog. Then the specific attributes of the bird will be null and void to the object of type dog.
If you need any further help then don't hesitate to contact me.
Edit #3: It would seem that there is a caveat in my code. After Polly's conversion, she still isn't taking on only one type. She isn't just a Dog, she's also still a Bird. I can still make her able to fly by calling polly->canFly=true; however, pollyDog->canFly=true still fails.