简体   繁体   English

C ++宏定义不清楚

[英]C++ macro definition unclear

Is this a macro defintion for a class or what exactly is it? 这是一个类的宏定义还是它究竟是什么?

#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) {};                                            \
}

It is a macro definition for an exception class. 异常类的宏定义。

It looks somebody wants you to write code like this: 看起来有人要你写这样的代码:

class my_exception EXCEPTIONCLASS_IMPLEMENTATION(my_exception, std::exception, "What a mess!")

The pre-processor will spit out: 预处理器将吐出:

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) {}; }

What exactly is it? 究竟是什么?

It is an abomination! 这是令人厌恶的!

它是异常的宏,用标准构造函数创建异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM