开发者

C++: Error: Unable to create variable object

开发者 https://www.devze.com 2023-01-25 06:27 出处:网络
I have a simple method: std::vector<string> start() { std::vector<std::string> deletedFiles; // << error appeared at this declaration

I have a simple method:

std::vector<string> start()
{
    std::vector<std::string> deletedFiles; // << error appeared at this declaration
}

Error: Unable to create variable object

What is wrong here?

Thanks in advance.开发者_JAVA百科


This similar program compiles without a hitch:

#include <vector>
#include <string>

std::vector<std::string> start()
{
    std::vector<std::string> deletedFiles;
    return deletedFiles;
}

int main()
{
    std::vector<std::string> deletedFiles = start();
    return 0;
}

Please double check your #includes and your std::s. You might want to add std:: to string in your return type.


Nothing, really. The error will be somewhere else. For instance, there's a missing return statement in the function, and you're missing #include's, but that's probably code you snipped.


Maybe you've missed a namespace prefix...

std::vector<string> start()

Should it be this?

 std::vector<std::string> start()
0

精彩评论

暂无评论...
验证码 换一张
取 消