CPP 中没有构造函数错误的实例

No instance of constructor error in CPP

本文关键字:错误 实例 构造函数 CPP      更新时间:2023-10-16

我试图创建一个函数来识别字符串中的匹配行。我的整个字符串保存在strStart中,strToMatch包含搜索字符串。以下是我的代码

void ExpertContextUser::removeMatchedString() {
        String line;
        String strStart="TestingnReturnsnrelatednresources";
        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=std::char_traits, _Allocator=std::分配器]" 匹配参数列表 参数类型为:(RWCString( istringstream streamAddtText(strStart(;

我找不到此错误的原因。

发生错误是因为istringstream构造函数采用std::string,而不是RWCString。如果您希望此功能正常工作,则需要提供从RWCStringstd::string的转换。

相关文章: