宏函数定义继承类

时间:2014-04-28 00:09:24   收藏:0   阅读:444
bubuko.com,布布扣
//: 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; }
bubuko.com,布布扣

输出结果:

A
B
C

 

宏函数定义继承类,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!