GET_SET
宏定义,用来生成get和set函数#ifndef _MAJIAOOBJECT_H
#define _MAJIAOOBJECT_H
#include <string>
using namespace std;
#define MAJIAO_FIELD_DEFINE(type, field) type field
#define GET_SET(access_permission, type, name) access_permission: MAJIAO_FIELD_DEFINE(type, name); public: inline void set##name(type v){ this->##name = v; } inline type get##name(){ return this->##name; }
class MajiaoObject {
public :
GET_SET(public, int, id)
MajiaoObject() { }
~MajiaoObject() { }
virtual string toString() { return ""; }
} ;
#endif // _MAJIAOOBJECT_H
原文:https://www.cnblogs.com/majiao61/p/14902584.html