, , .
#include <iostream>
class CBase
{
public:
CBase() : a(0), b(0), c(0) {}
CBase(int aa, int bb, int cc) : a(aa), b(bb), c(cc) {}
int a, b, c;
};
class CInterface
{
public:
CInterface(CBase &b)
: base(b), x(b.a), y(b.b), z(b.c)
{
}
int &x, &y, &z;
private:
CBase &base;
};
int main()
{
CBase base(1, 2, 3);
CInterface iface(base);
std::cout << iface.x << ' ' << iface.y << ' ' << iface.z << std::endl;
std::cout << base.a << ' ' << base.b << ' ' << base.c << std::endl;
iface.x = 99;
base.c = 88;
std::cout << iface.x << ' ' << iface.y << ' ' << iface.z << std::endl;
std::cout << base.a << ' ' << base.b << ' ' << base.c << std::endl;
return 0;
}