Dear all, i have two classes which are computer and floppy disk.
When i put
#include "FloppyDisk.h"
#include "Computer.h"
in main, then compiler generates error of computer undeclared
When i
#include "Computer.h"
#include "FloppyDisk.h"
in main, then compiler generates error of floppy disk undeclared.
What is the problem?
I have check there is no cyclic dependency between the header file.
These are the implementation file for reference.
#include "EquipmentAttributes.h"
#include "EquipmentVisitor.h"
#include "Computer.h"
#include "BoostHeader.h"
#include <algorithm>
// =============================================
computer::computer()
: cont()
{
}
// =============================================
void computer::add(equipment* equip)
{
cont.push_back(equip);
}
// =============================================
void computer::remove(equipment* equip)
{
vecIte myIte;
myIte = std::find(cont.begin(), cont.end(), equip);
cont.erase(myIte);
}
// =============================================
void computer::accept(equipmentVisitor* visitor)
{
BOOST_FOREACH(equipment* anEquip, cont)
{
anEquip->accept(visitor);
}
visitor->visitComputer(this);
}
// =============================================
computer::equipVec computer::getCont() const
{
return cont;
}
#include "FloppyDisk.h"
#include "EquipmentAttributes.h"
#include "EquipmentVisitor.h"
// =============================================
floppyDisk::floppyDisk(const int userPrice, const std::string& userName)
: state(new equipmentState(userPrice, userName) )
{
}
// =============================================
void floppyDisk::accept(equipmentVisitor* visitor)
{
visitor->visitFloppyDisk(this);
}
// =============================================
floppyDisk::equipPtr floppyDisk::getState() const
{
return state;
}
Please help.
Thanks.
Are you using the same header include guard in each file, e.g.:
The
MY_INCLUDE_GUARDneeds to be a unique name in each header.