CC_SYNTHESIZE 类中声明定义数据 和操作该数据的函数
- #include <iostream>
- using namespace std;
- #define CC_SYNTHESIZE(varType, varName, funName)
- protected: varType varName;
- public: virtual varType get##funName(void) const { return varName; }
- public: virtual void set##funName(varType var){ varName = var; }
- class plane
- {
- CC_SYNTHESIZE(int, hp, Hp)
- };
- int main()
- {
- plane *p = new plane;
- p->setHp(1);
- }