Figure 1: The problem — implementation of GetSize in derived classes is identical except for type of derived class

class ABase
{
protected:
    virtual size_t GetSize()=0;
    ...
    void UseGetSize()
    {
    ...
    size_t size = GetSize();
    ...
    }
};
 
class CDerivedOne : public ABase 
{
protected:
    virtual size_t GetSize() 
    { return sizeof(CDerivedOne);}
};

class CDerivedTwo: public ABase 
{
protected:
    virtual size_t GetSize() 
    { return sizeof(CDerivedTwo);}
};