宏函数定义继承类

//: ORDER.CPP -- Order of constructor calls 
// with inheritance
#include <iostream.h>

#define inherit(derived, base) \
class derived : public base { \
public: \
  derived() { cout << #derived << endl; } \
};

class X {};
inherit(A, X)
inherit(B, A)
inherit(C, B)

main() { C c; }

输出结果:

A
B
C

 

posted @ 2014-04-27 21:32  findumars  Views(317)  Comments(0Edit  收藏  举报