I'm doing my project which I was assigned at my C++ classes. It's about fire brigades. I created the basic classes and member functions declarations. However, in one class I get the error and I cannot come up with any idea how to solve it. Here is the thing.
#ifndef FIREFIGHTER_H
#define FIREFIGHTER_H
#include <string>
#include "Firebrigade.h"
usingnamespace std;
class Firefighter
{
public:
enum rank_type
{
firefighter,
sergeant,
lieutenant,
captain,
battalion_chief,
division_chief,
assistant_chief,
chief
};
private:
Firebrigade* which_firebrigade; //Describes to which unit the firefighter belongs.
unsigned id; //unique ID
string name;
rank_type what_rank;
bool on_mission; //Whether the firefighter is currently on a mission or not.
public:
void promote();
Firefighter(unsigned id, string name, rank_type what_rank);
~Firefighter();
};
#endif
I'm using Visual Studio 2010. While trying to build solution, I get errors: Error 1 error C2065: 'Firefighter' : undeclared identifier c:\users\pawel\desktop\c++ project\fire brigade\fire brigade\firebrigade.h 14
I think... When you include "Node.h", it includes "Firefighter.h", which includes "Firebrigade.h" before any of the class definitions. Just add class Firefighter; (after the includes, before the class) in "Firebrigade.h". Your probably having a similar problem with "Truck.h".