#include <iostream>
using namespace std;
class A
{
public:
int x;
int y;
virtual int add() = 0;
};
class B
{
public:
int a;
int b;
virtual int sub() = 0;
};
class C : public A, public B
{
public:
C() { x = 1; y = 2; z = 3; a = 4; b = 5; c = 6; }
int c;
int z;
virtual int add() { return a + z; }
virtual int sub() { return c - x; }
int mul() { return b * y; };
};
int main()
{
A *p = new C;
cout << p->add() << endl;
cout << ((B *)p)->sub() << endl;
cout << ((C *)p)->mul() << endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQQp7CnB1YmxpYzoKICAgIGludCB4OwogICAgaW50IHk7CiAgICB2aXJ0dWFsIGludCBhZGQoKSA9IDA7Cn07CgpjbGFzcyBCCnsKcHVibGljOgogICAgaW50IGE7CiAgICBpbnQgYjsKICAgIHZpcnR1YWwgaW50IHN1YigpID0gMDsKfTsKCmNsYXNzIEMgOiBwdWJsaWMgQSwgcHVibGljIEIKewpwdWJsaWM6CiAgICBDKCkgeyB4ID0gMTsgeSA9IDI7IHogPSAzOyBhID0gNDsgYiA9IDU7IGMgPSA2OyB9CiAgICBpbnQgYzsKICAgIGludCB6OwogICAgdmlydHVhbCBpbnQgYWRkKCkgeyByZXR1cm4gYSArIHo7IH0KICAgIHZpcnR1YWwgaW50IHN1YigpIHsgcmV0dXJuIGMgLSB4OyB9CiAgICBpbnQgbXVsKCkgeyByZXR1cm4gYiAqIHk7IH07Cn07CgppbnQgbWFpbigpCnsKICAgIEEgKnAgPSBuZXcgQzsKICAgIGNvdXQgPDwgcC0+YWRkKCkgPDwgZW5kbDsKICAgIGNvdXQgPDwgKChCICopcCktPnN1YigpIDw8IGVuZGw7CiAgICBjb3V0IDw8ICgoQyAqKXApLT5tdWwoKSA8PCBlbmRsOwp9Cg==