我有这段代码,它使用 Sun Studio 编译,但在 g++ 中出现错误
DBManager & DBManager::operator >> (UtlString &value)
{
//## begin DBManager::operator>>%921890065.body preserve=yes
if(_state == DBMRan){
_reader >> static_cast<std::string>(value);
}
return *this;
//## end DBManager::operator>>%921890065.body
}
DBManager.cpp:263: error: no match for âoperator>>â in â((DBManager*)this)->DBManager::_reader >> std::basic_string<char, std::char_traits<char>, std::allocator<char> >(((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(&((jda::UtlString*)value)->jda::UtlString::<anonymous>))))â
DBReader.h:50: note: candidates are: virtual DBReader& DBReader::operator>>(char&)
DBReader.h:51: note: virtual DBReader& DBReader::operator>>(unsigned char&)
DBReader.h:52: note: virtual DBReader& DBReader::operator>>(short int&)
DBReader.h:53: note: virtual DBReader& DBReader::operator>>(short unsigned int&)
DBReader.h:54: note: virtual DBReader& DBReader::operator>>(int&)
DBReader.h:55: note: virtual DBReader& DBReader::operator>>(unsigned int&)
DBReader.h:56: note: virtual DBReader& DBReader::operator>>(long int&)
DBReader.h:57: note: virtual DBReader& DBReader::operator>>(long long int&)
DBReader.h:58: note: virtual DBReader& DBReader::operator>>(long unsigned int&)
DBReader.h:59: note: virtual DBReader& DBReader::operator>>(long long unsigned int&)
DBReader.h:60: note: virtual DBReader& DBReader::operator>>(float&)
DBReader.h:61: note: virtual DBReader& DBReader::operator>>(double&)
DBReader.h:62: note: virtual DBReader& DBReader::operator>>(DBDateTime&)
DBReader.h:63: note: virtual DBReader& DBReader::operator>>(DBBlob&)
DBReader.h:64: note: virtual DBReader& DBReader::operator>>(std::string&)
DBReader.h:65: note: virtual DBReader& DBReader::operator>>(DBNullIndicator&)
otlv4.h:35416: note: otl_connect& operator>>(otl_connect&, otl_stream&)
正如您在上面的错误消息中看到的那样,DBReader 类具有 operator>>,它通过引用获取 std::string 并且 UtlString 类是从 std::string 派生的,因此 static_cast 应该不是问题,但编译器仍然抱怨没有匹配的方法. 还有谁能告诉我如何删除出现在错误消息中的字符。
谢谢