keep getting an error where it says "Unit" was not declared
Feb 9, 2014 at 8:06pm UTC
Everytime i compile my class it keeps telling me that "Unit" and "user" were not declared in this scope and i cannot figure out what the problem is.
here is my header file for the class
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
#ifndef _Item_included_
#define _Item_included_
#include <string>
#include "Entity.h"
using namespace std;
class Item: public Entity
{
public :
virtual void setWeight(int nWeight);
int getWeight();
virtual void setValue(int nValue);
int getValue();
virtual void setQuantiy(int nQuantity);
int getQuantity();
virtual void use(Unit &user);
private :
int m_nWeight;
int m_nValue;
int m_nQuantity;
};
#endif
and the .cpp file
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
#include "Item.h"
#include <string>
using namespace std;
int Item::getWeight()
{
return m_nWeight;
}
void Item::setWeight(int nWeight)
{
m_nWeight = nWeight;
}
int Item::getValue()
{
return m_nValue;
}
void Item::setValue(int nValue)
{
m_nValue = nValue;
}
int Item::getQuantity()
{
return m_nQuantity;
}
void Item::setQuantity(int nQuantity)
{
m_nQuantity = nQuantity;
}
void Item:: use(Unit &user)
{
nQuantity--;
nValue--;
nWeight--;
}
Feb 9, 2014 at 9:22pm UTC
What and where is the definition of Unit
?
Topic archived. No new replies allowed.