Determining size of an overloaded C++ class-Collection of common programming errors

If you are able to change source classes’ design, you can totally replace dynamic polymorphism (which uses virtual functions) with static polymorphism and use the CRTP idiom:

template 
class Base
{
public:
    int getSize()
    { return sizeof(TDerived); }

    void print()
    {
          std::cout
             getSize()