不学习是会 被override的!.|

勒勒乐了

园龄:3年4个月粉丝:5关注:3

记录一个很傻的错误(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 @   勒勒乐了  阅读(1088)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起