Error - undefined class.

Hi again. I get two errors which I can't locate. I would be very grateful if you could help me (again :) ).

Headquarters.h:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//DONE

#ifndef HEADQUARTERS_H
#define HEADQUARTERS_H
#include "node.h"
#include "Main_trucks_list.h" //Isn't it defined here?
#include "Main_firefighters_list.h" //And here?
#include <string>

using namespace std;

class Firebrigade;
class Accident;
class Main_trucks_list;
class Main_firefighters_list;

class Headquarters
{
private:
	Main_trucks_list my_main_trucks_list;  //ERROR HERE
	Main_firefighters_list my_main_firefighters_list;   //ERROR HERE
	node<Accident>* accident_head;	//head of the list of accidents
	node<Firebrigade>* firebrigade_head;	//head of the list of firebrigades
	string town;
	string street;
	friend class Accident;
	friend class Firebrigade;
	friend class Firefighter;
	friend class Truck;

public:
	node<Firebrigade>* get_firebrigade_head() const;	//DONE
	bool insert_firebrigade(Firebrigade*);			//DONE
	bool delete_firebrigade(string address);		//DONE
	bool create_accident(string place, unsigned how_many_firefighters);		//DONE
	unsigned count_accidents() const;				//DONE
	bool remove_accident(unsigned id);				//DONE
	void display_accidents() const;					//DONE
	Headquarters(string town, string street);		//DONE
	~Headquarters();								//DONE
};

#endif 


The errors:
Error 1 error C2079: 'Headquarters::my_main_trucks_list' uses undefined class 'Main_trucks_list' c:\users\pawel\desktop\c++ project\fire brigade\fire brigade\headquarters.h 20


Error 2 error C2079: 'Headquarters::my_main_firefighters_list' uses undefined class 'Main_firefighters_list' c:\users\pawel\desktop\c++ project\fire brigade\fire brigade\headquarters.h 21

I can't understand why I get that. In lines 14 and 15 I declared the classes which are defined in their headerfiles. What's the problem?


Additional:

Main_trucks_list.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//DONE

#pragma once
#include "Truck.h"

class Truck;

class Main_trucks_list
{
private:
	node<Truck>* head;

public:
	bool insert_truck(Truck*);
	bool remove_truck(unsigned id);
	Main_trucks_list(void);
	~Main_trucks_list(void);
	Truck* find(unsigned id) const;
};


Main_firefighters_list.h:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//DONE

#pragma once
#include "Firefighter.h"

class Firefighter;

class Main_firefighters_list
{
private:
	node<Firefighter>* head;

public:
	bool insert_firefighter(Firefighter*);
	bool remove_firefighter(unsigned id);
	Main_firefighters_list(void);
	~Main_firefighters_list(void);
	Firefighter* find(unsigned id) const;
};
Look at the preprocesser output so you can see what's actuall being passed to the compiler.

It looks like you're using Microsoft's compiler. If you're using Visual C++:
1. Select the C++ project source file in Solution Explorer
2. Select Properties
3. Open tree Confguration Properties -> C++ -> Preprocessor
4. Set option "Generate Preprocessed File" to Yes
5. Set option "Keep Comments" to Yes
6. Press OK
7. Compile the file
8. Open the preprocessed output, it'll have the same name as the source file with a .i extension.

This is a single file with all the included files amalamated and macros resolved. Start reading from the end and work your way back.

Remember to switch off the preprocessor output when you want to compile your code again.
Topic archived. No new replies allowed.