Teo Alivanoglou
Teo Alivanoglou

Reputation: 89

error C2065 and i have no idea what is wrong

#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;
    }
};

This is a piece of code I'm writing and I get these 2 errors:

error C2653: 'FileManager' : is not a class or namespace name

error C3861: 'createVector': identifier not found

The thing is I've looked all over the internet and I really can't see what is wrong, my head hurts a lot, and time is limited. I really didn't want to ask here because you probably have more important questions to answer. Any help is appreciated.

Upvotes: 0

Views: 69

Answers (1)

Alex
Alex

Reputation: 10126

You should either define FileManager before Admin class or use forward declaration to make it visible for compiler.

Upvotes: 1

Related Questions