这是一个类的宏定义还是它究竟是什么?
#define EXCEPTIONCLASS_IMPLEMENTATION(name, base, string) : public base \
{ \
public: \
name() : base(string) {} \
name(const x::wrap_exc& next) : base(string,next) {}; \
name(const x::wrap_exc& prev, const x::wrap_exc& next) : \
base(prev, next) {}; \
}
Run Code Online (Sandbox Code Playgroud)
它是异常类的宏定义.
看起来有人要你写这样的代码:
class my_exception EXCEPTIONCLASS_IMPLEMENTATION(my_exception, std::exception, "What a mess!")
Run Code Online (Sandbox Code Playgroud)
预处理器将吐出:
class my_exception : public std::exception { public: my_exception() : std::exception("What a mess!") {} my_exception(const x::wrap_exc& next) : std::exception("What a mess!",next) {}; my_exception(const x::wrap_exc& prev, const x::wrap_exc& next) : std::exception(prev, next) {}; }
Run Code Online (Sandbox Code Playgroud)
究竟是什么?
这是令人厌恶的!
| 归档时间: |
|
| 查看次数: |
614 次 |
| 最近记录: |