There is no reason you should ever have a Script::Variable pointer pointing to a Script::CppClass instance. They are two completely different, unrelated classes. I don't even think that is legal, you are forcing the compiler to accept it with the C style cast, but it will yield undefined behavior. It's like having an int pointer pointing to a string.

Again, what are you trying to accomplish by storing CppClass addresses in a Variable pointer? Are you trying to make a list of Variables that could be different things, including possibly a CppClass? If so, then Variable would be a base class (either directly or indirectly) of CppClass, or they would share a common base class. There are other ways to accomplish that, but fixing your inheritance hierarchy is probably the best bet.