记录一个很傻的错误(C++)
使用的vscode写代码,导入了vector,memory,然后忘了导入string。但是代码中能够提示std::string也就让我忘了导入string。然后就莫名其妙的报错了。找了很久的错。记录下
std::string& StrBlobPtr::deinf() const{
auto p = check(curr, "dereference past end"); // check必须是const的
return (*p)[curr];
}
报错//could not bind to an lvalue of type 'const char [21]'
然后好吧,我以为是什么const的问题,然后把字符串单独赋值依旧报错
std::string& StrBlobPtr::deinf() const{
std::string msg = "dereference past end"
auto p = check(curr,msg ); // check必须是const的
return (*p)[curr];
}
error: implicit instantiation of undefined template 'std::__1::basic_string<char>'
这才发现不对头呀,然后看头文件,发现没有#include<string>
总结:vscode有时候能够提示没有导入的标准库函数????很迷,以后注意啦
本文来自博客园,作者:勒勒乐了,转载请注明原文链接:https://www.cnblogs.com/matytan/p/15519540.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步