记录一个很傻的错误(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有时候能够提示没有导入的标准库函数????很迷,以后注意啦

posted @ 2021-07-06 11:59  勒勒乐了  阅读(1248)  评论(0)    收藏  举报