Original Post
Why does downcasting have a runtime performance cost? It seems to me that this should be taken care of by the compiler, for the following reason : When the compiler sees the downcast, it knows that from now on it needs to use the virtual table belonging to the subclass. But it knows perfectly well where it put that table, so all it needs to do is add an offset to its method calls. Now, I understand that this theory is not correct, but I don't understand why. Could someone explain it to me?