我正在 try catch 如下所示的异常 -
try {
} catch (const std::exception& ex) {
cout << "An exception occurred when executing query. " << ex << endl;
}
但每次我都会收到这个错误 -
no match for operator<< in std::operator<< <std::char_traits<char> >((* & std::cout), ((const char*)"An exception occurred when executing query. ")) << ex
知道我在这里做错了什么吗?
最佳答案
使用这个
cout << "An exception occurred when executing query. " << ex.what() << endl;
<<
exception
中的运算符未重载类。
关于c++ - catch block 让我无法匹配运算符(operator)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19410222/