class Base
{
    // Note: You can make this protected, but then you need `friend class Common;` in A, B.
public:
    int x, y;
};

struct Common
{
    // Hide implementation details here, has access data of type T
    // (only public stuff can be accessed, unless Common is a friend of T!)
    template <class T>
    int sum(T *_this) const {
        return _this->x + _this->y;
    }
};

class A : public Base, private Common
{
public:
    // Only forward to the actual implementation in Common
    int sum() const { return Common::sum(this); }
};

class B : public Base, private Common
{
public:
    // Only forward to the actual implementation in Common
    int sum() const { return Common::sum(this); }
};


int main() {
    return 0;
}