Problem with Vectors Revisited

I know most of you are probably getting annoyed with me but this is the last thread ill make for a while i promise and I've finished my project and there are only 3 errors.

1
2
3
1>c:\users\david\documents\visual studio 2010\projects\employee database\main.cpp(38): error C3861: 'AddManager': identifier not found
1>c:\users\david\documents\visual studio 2010\projects\employee database\main.cpp(41): error C3861: 'AddEngineer': identifier not found
1>c:\users\david\documents\visual studio 2010\projects\employee database\main.cpp(44): error C3861: 'AddResearcher': identifier not found


All three are pretty much the same with small tweaks so ill use AddManager to show you what the code looks like..

in main()
 
AddManager(database);


in Manager.h
 
void	AddManager(vector<Employee*>& database);


in Manager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void	Manager::AddManager(vector<Employee*>& database)
{
	cout << "First Name : ";
	std::string firstName;
	cin >> firstName;
	cout << "Last Name : ";
	std::string lastName;
	cin >> lastName;
	cout << "Salary : ";
	int salary;
	cin >> salary;
	cout << "Meetings per Week : ";
	int meetingsPerWeek;
	cin >> meetingsPerWeek;
	cout << "Vacations Days per Year : ";
	int vacationDaysPerYear;
	cin >> vacationDaysPerYear;
	database.push_back(new Manager(firstName, lastName, salary, 
									meetingsPerWeek, vacationDaysPerYear));
}
Last edited on
is main.cpp #including Manager.h?
@dish
Yup! and it includes Engineer.h and Researcher.h
Something's missing. We'll need to see more code to diagnose.
are you calling AddManager on an object? If AddManager is a member function of some class you need to call it on an object of that class like

1
2
Manager man;
man.AddManager(vec);


not just try to call it out of nowhere like your example.
Last edited on
How would i do it so i could call it out of no where? would i have to make it a function in the same file as main?
Not sure why you would want to call the function without first constructing the object of the class that it belongs to. If it were static you could do that but then you might end up writing terrible code. It's tough to give you advice without having a better idea of what you are trying to do. I assume Manager inherits from Employee.
I probably should have planned more, i diddnt expect the project to be as big as it got. The point of AddManager() was to create an instance of Manager and place it in the vector.

I ended up just putting the function in the same file as main and it works fine now.
Topic archived. No new replies allowed.