2

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.

1
  • 2
    Please post the complete code. Commented Nov 17, 2010 at 9:35

3 Answers 3

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

hi, I have already included vector and string and return but it is till giving that error. thanks!
@JoesyXHN: It would be great if you could post a complete source file that exhibited the problem along with the command you use to compile it. Then we might be able to reproduce your problem locally.
0

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.

Comments

0

Maybe you've missed a namespace prefix...

std::vector<string> start()

Should it be this?

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.