C ++:错误:无法创建变量对象(C++: Error: Unable to create variable object)
我有一个简单的方法:
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.
最满意答案
这个类似的程序编译顺利:
#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; }请仔细检查你的#include和你的std:: s。 您可能希望在返回类型中添加std:: to string 。
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.
更多推荐
发布评论