So let's say I have two classes that inherit a base class that has a pure virtual function. Both of the classes implement their own version of that function, but don't add additional member variables so they have the same size. Now sometimes, in the middle of the execution of the program, I want to convert one class to the other without copying all its data. So basically I want to make it use the virtual table of the other class. Is there a portable way of doing this?
The portable way to do this would be to implement your own class system that actually has virtual-pointers that can be copied.
There is no such thing as a virtual-pointer in standard C++.