我试图创建一个函数来识别字符串中的匹配行。我的整个字符串保存在strStart和strToMatch包含搜索字符串。以下是我的代码CPP中没有构造函数错误的实例
void ExpertContextUser::removeMatchedString() {
String line;
String strStart="Testing\nReturns\nrelated\nresources";
String strToMatch="Test";
istringstream streamAddtText(strStart);
while(std::getline(streamAddtText, line)) {
cout << line << "Function" << endl;
if(line.index(strToMatch) > 0) {
TraceMessage <<" Test Success" << endl;
}
}
}
当我编译我的代码
,我收到以下错误
“../user_model_impl.cxx”,行234:错误#2289:没有构造 实例“标准:: basic_istringstream < _CharT,_Traits, _Allocator> :: basic_istringstream [与_CharT =炭, _Traits =标准:: char_traits,_Allocator =标准::分配器]” 参数列表 参数类型相匹配:(RWCString ) istrings tream streamAddtText(strStart);
我无法找到此错误的原因。
istringstream streamAddtText(strStart); istringstream在构造函数中将字符串作为参数,不确定什么是RWCString。 – Kunal
RWCString是来自Rogue wave库的模板。我改变了代码来使用字符串,但我仍然得到相同的错误 – Mohan
什么是你的代码中的字符串?也许它应该是'std :: string'? –