Vectors + Classes = Confusing
Hullo again, I've had a few suggestions recently to move towards vectors instead of just regular old arrays, so I've started looking into them with more depth. Here's what I've gotten so far:
Code:
//Create a vector with 10 members
std::vector<int> MyInts(10);
//Create a vector with an undefined amount of members
std::vector<int> MyInts();
//And later, say I want to add an element to the vector (I.e. the integer 30)
MyInts.push_back(30)
And that's all pretty decent with me, but my purpose here is to make a vector of classes.
Code:
class cORGANISM
{
public:
cORGANISM(void);
virtual ~cORGANISM(void);
void Initialise(int HisAge);
private:
int Age;
};
So I've tried going about it like this:
Code:
std::vector<cORGANISM> Dude();
Dude.push_back(/*I can't figure out what goes in here*/);
Dude[0].Initialise(50); //Make this dude 50 years old
My thoughts for the push_back() are to somehow pass the Constructor?? But I just haven't been able to search up a thread that covers this.
Thanks for any insight,
Erik