#include using namespace std; class A { protected: typedef A self_t; public: A(){} virtual ~A() {} self_t &operator=(const self_t &a){ cout << "A::operator=(A)"; return *this; } void hoge(const self_t &a){ cout << "A::hoge(A)"; } }; class B : public A { protected: typedef A super_t; typedef B self_t; public: B() : super_t() {} ~B() {} self_t &operator=(const A &a){ cout << "B::operator=(A)"; return *this; } void hoge(const A &a){ cout << "B::hoge(A)"; } }; class C : public B { protected: typedef A base_t; typedef B super_t; typedef C self_t; public: C() : super_t() {} ~C(){} self_t &operator=(const A &a){ cout << "C::operator=(A)"; return *this; } void hoge(const A &a){ cout << "C::hoge(A)"; } }; int main(){ A a; B b; C c; cout << "a = a => "; a = a; cout << endl; cout << "a = b => "; a = b; cout << endl; cout << "a = c => "; a = c; cout << endl; cout << "b = a => "; b = a; cout << endl; cout << "b = b => "; b = b; cout << endl; cout << "b = c => "; b = c; cout << endl; cout << "c = a => "; c = a; cout << endl; cout << "c = b => "; c = b; cout << endl; cout << "c = c => "; c = c; cout << endl; cout << "a.hoge(a) => "; a.hoge(a); cout << endl; cout << "a.hoge(b) => "; a.hoge(b); cout << endl; cout << "a.hoge(c) => "; a.hoge(c); cout << endl; cout << "b.hoge(a) => "; b.hoge(a); cout << endl; cout << "b.hoge(b) => "; b.hoge(b); cout << endl; cout << "b.hoge(c) => "; b.hoge(c); cout << endl; cout << "c.hoge(a) => "; c.hoge(a); cout << endl; cout << "c.hoge(b) => "; c.hoge(b); cout << endl; cout << "c.hoge(c) => "; c.hoge(c); cout << endl; }