gpt4 book ai didi

c++ - 错误 C2065,我不知道出了什么问题

转载 作者:行者123 更新时间:2023-11-28 06:14:41 25 4
gpt4 key购买 nike

#include <iostream>
#include <string>
#include <fstream>
#include <vector>

using namespace std;

class Admin {

static void editUser() {
vector<User> usr = FileManager::createVector(); //errors are here

...

}
};

class FileManager {
public:
static vector<User> createVector() {
string name;
string surname;
string code;
float miles;
float balance;
vector<User> users;

ifstream getUsers("users.txt");

while (getUsers >> name >> surname >> code >> miles >> balance) {
User temp(name, surname, code, miles, balance);
users.push_back(temp);
}

return users;
}
};

这是我正在编写的一段代码,我遇到了这两个错误:

错误 C2653:“FileManager”:不是类或命名空间名称

error C3861: 'createVector': 找不到标识符

问题是网上找遍了,实在是看不出哪里不对,头好痛,时间又有限。我真的不想在这里问,因为你可能有更重要的问题要回答。任何帮助表示赞赏。

最佳答案

您应该在 Admin 类之前定义 FileManager 或使用 forward declaration使其对编译器可见。

关于c++ - 错误 C2065,我不知道出了什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30561499/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com