今日看到了一句话,#define private public瞬间吓尿了。这define好厉害。好迷惑人啊。所有东西都public了。
http://blog.youkuaiyun.com/wangjieest/article/details/7978382
C++限制访问数据类型的bug啊。一句话就突破了
关于define与typedefi的区别。一个预处理,一个编译器。以下引自stackoverflow。
#define is
a preprocessor token: the compiler itself will never see it.
typedef is
a compiler token: the preprocessor does not care about it.
You can use one or the other to achieve the same effect, but it's better to use the proper one for your needs
#define MY_TYPE int
typedef int My_Type;
When things get "hairy", using the proper tool makes it right
#define FX_TYPE void (*)(int)
typedef void (*stdfx)(int);
void fx_typ(stdfx fx); /* ok */
void fx_def(FX_TYPE fx); /* error */
本文探讨了C++中使用#define与typedef的区别,通过具体的示例展示了两者不同的应用场景及效果。并讨论了一个有趣的#define用法,该用法能够改变类成员的访问权限。
2885

被折叠的 条评论
为什么被折叠?



