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:
And that's all pretty decent with me, but my purpose here is to make a vector of classes.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)
So I've tried going about it like this:Code:class cORGANISM { public: cORGANISM(void); virtual ~cORGANISM(void); void Initialise(int HisAge); private: int Age; };
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.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
Thanks for any insight,
Erik



LinkBack URL
About LinkBacks



