为了账号安全,请及时绑定邮箱和手机立即绑定

cocos2d-x 那个封装好的get set方法宏定义叫什么?

/ 猿问

cocos2d-x 那个封装好的get set方法宏定义叫什么?

SMILET 2018-11-16 11:03:22

cocos2d-x 那个封装好的get set方法宏定义叫什么


查看完整描述

1 回答

?
狐的传说

CCPlatformMacros.h 在这个头文件里面自己找自己需要的 /** CC_SYNTHESIZE is used to declare a protected variable.
We can use getter to read the variable, and use the setter to change the variable.
@param varType : the type of variable.
@param varName : variable name.
@param funName : "get + funName" is the name of the getter.
"set + funName" is the name of the setter.
@warning : The getter and setter are public inline functions.
The variables and methods declared after CC_SYNTHESIZE are all public.
If you need protected or private, please declare.
*/
#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; }

#define CC_SYNTHESIZE_PASS_BY_REF(varType, varName, funName)\
protected: varType varName;\
public: virtual const varType& get##funName(void) const { return varName; }\
public: virtual void set##funName(const varType& var){ varName = var; }

#define CC_SYNTHESIZE_RETAIN(varType, varName, funName) \
private: varType varName; \
public: virtual varType get##funName(void) const { return varName; } \
public: virtual void set##funName(varType var) \

查看完整回答
反对 回复 2018-12-11

添加回答

回复

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信