首先建立一个头文件oop.h,内容如下:
#ifndef OOP_H
#define OOP_H
#define PROPERTY_DECL(className,propertyName) \
public: className get##propertyName() { return m_##propertyName; } \
public: void set##propertyName(className val) { m_##propertyName = val; } \
private: className m_##propertyName;
#define APP_INIT(MainClass) \
int main(int argc,char **argv) \
{ \
MainClass instance; \
}
#endif // OOP_H
PROPERTY_DECL宏的作用就是声