The compiler needs to know what an "Object" is before it can generate the necessary code. There is nothing in the code you show which has the struct Obj (what we seem to have taken to calling Object instead) you cited in your original post. The solution therefore is to place the struct definition in your code prior to the class. Also, note that your class works with several std::string data members so you should also remember to include the <string> class.
Code:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct Object
{
string name;
int num;
string description;
};
class CCharacter{
string _name, _genre;
int _inRoom, _status;
bool _activeCharacter;
public:
std::vector<Object> objects;
CCharacter (string,string, int, bool, int);
string getName () {return (_name);}
void addObject(const Object& item);
};
void CCharacter::addObject(const Object& item)
{
objects.push_back(item);
}
CCharacter::CCharacter (string name, string genre,int inRoom, bool activeCharacter, int status) {
_name=name;
_genre = genre;
}
Incidentally, you should prefer initialization lists for construction and try to keep in mind const correctness, member functions which do not alter the state of the class they are called upon ("get" member functions for example) should be declared const.
Code:
class CCharacter{
...
string getName () const {return (_name);}
...
};
CCharacter::CCharacter (string name, string genre,int inRoom, bool activeCharacter, int status)
: _name(name), _genre(genre), _inRoom(inRoom), _activeCharacter(activeCharacter), _status(status)
{
}