Hmm, I have a new problem now, I was trying to switch from using a vector of Monsters to using a vector of pointers to the Monsters like matsp suggested, but it doesn't like it. What I had originally was:
Code:
Monster Monster1;
Monster Monster2;
vector<Monster> MonsterList (30);
int main(int argc, char *argv[])
{
MonsterList.push_back(Monster1);
MonsterList.push_back(Monster2);
MonsterList.at(0).xpos = 500;
}
Now, I changed that to:
Code:
Monster Monster1;
Monster Monster2;
vector<Monster*> MonsterList (30);
int main(int argc, char *argv[])
{
MonsterList.push_back(&Monster1);
MonsterList.push_back(&Monster2);
MonsterList.at(0)->xpos = 500;
}
It compiles fine, but when it runs it throws an error ("process returned 3", I'm using Codeblocks with mingw). But if I replace the pushbacks like so:
Code:
Monster Monster1;
Monster Monster2;
vector<Monster*> MonsterList (30);
int main(int argc, char *argv[])
{
MonsterList[0]=&Monster1;
MonsterList[1]=&Monster2;
MonsterList.at(0)->xpos = 500;
}
That runs fine. So I'm thinking that for some reason the vector's pushback method doesn't like my pointers. Am I doing something wrong?