Having trouble when trying to create a class using another class(and 2 inner classes), I think it might be a syntax problem.
The first class
class listitem
{
//listitem.h(11)
public:
//MONSTER CLASS
static class monster
{
public:
monster(string thename);
monster(void);
~monster(void);
private:
string name;
int level;
};
//PLAYER CLASS
static class player
{
public:
player(string _pname, int _plevel, int _maxhp, int _currhp);
player(void);
~player(void);
private:
string pname;
int plevel;
int maxhp;
int currhp;
};
public:
listitem(player member, monster head);
~listitem(void);
private:
player a;
monster b;
//other fields
};
The second class is where I encounter a problem:
class hatelist
{
private:
vector<listitem> thelist;
public:
hatelist(listitem newlist);
int addNewListItem(listitem item);
hatelist(void);
~hatelist(void);
};
The implementation of the offending code:
hatelist::hatelist(listitem inputlist)
{ //hatelist.cpp(6)
thelist.push_back(inputlist);
}
1>hatelist.cpp 1>c:\...\listitem.h(11) : error C2011: 'listitem' : 'class' type redefinition 1>c:\...\listitem.h(11) : see declaration of 'listitem' 1>c:\...\hatelist.cpp(6) : error C2027: use of undefined type 'listitem' 1>c:\...\listitem.h(11) : see declaration of 'listitem' 1>c:\...\hatelist.cpp(6) : error C2227: left of '->{dtor}' must point to class/struct/union/generic type
Any help would be appreciated.