C ++:错误:无法创建变量对象(C++: Error: Unable to create variable object)

编程入门 行业动态 更新时间:2024-10-16 08:28:39
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.

更多推荐

本文发布于:2023-08-07 14:33:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464537.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   对象   错误   Error   object

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!