首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

std:exception的带参数结构 为什么用g++编译通不过

2013-11-18 
std::exception的带参数构造 为什么用g++编译通不过expbeaut.cpp:97:44: 错误: 对‘std::exception::except

std::exception的带参数构造 为什么用g++编译通不过
expbeaut.cpp:97:44: 错误: 对‘std::exception::exception(const char [20])’的调用没有匹配的函数
expbeaut.cpp:97:44: 附注: 备选是:
In file included from /usr/include/c++/4.7/ios:40:0,
                 from /usr/include/c++/4.7/ostream:40,
                 from /usr/include/c++/4.7/iostream:40,
                 from expbeaut.cpp:1:
/usr/include/c++/4.7/exception:65:5: 附注: std::exception::exception()
/usr/include/c++/4.7/exception:65:5: 附注:   备选需要 0 实参,但提供了 1 个
/usr/include/c++/4.7/exception:62:9: 附注: constexpr std::exception::exception(const std::exception&)
/usr/include/c++/4.7/exception:62:9: 附注:   no known conversion for argument 1 from ‘const char [20]’ to ‘const std::exception&’

[解决办法]

引用:
Quote: 引用:

不要用那个, 那是MS搞得巫术, 不标准。


g++也不是完全的c++标准 是gnu自己的标准


g++的巫术也一样不要用。

好吧,这样说确实不准确, 用用倒也无妨。

std::exception倾向于做为所有异常的基类,人这个角度讲它不应该有任何数据成员,只有非常虚的东西才有可能适合所有情况。

自己定义一个异常类,从std::exception继续。或者使用 runtime_error, logic_error(说实话,我对这两个标准异常类不是很感冒)

热点排行