Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C++ vector of objects

Name: Anonymous 2009-07-13 18:46

How the FUCK do I use the iterator (or anything) to access a method of an object contained in a vector (or even a list)??? I've seen it done but for some reason it still won't work in my code...

Also:  How do I maintain a vector/list of dynamically created (ie. with new) objects... the vector/list would be a member of another class, and I would use methods of that class to add or delete objects from that vector or list.

This part may also be what I'm doing wrong, but the iterator thing keeps giving me shit too.  I will post my code in pastebin if it still won't work.

Name: Anonymous 2009-07-14 2:01

>>4
No, that doesn't do what I want.  I put it into less shitty words here:

I have 2 classes, and ClassA has a vector of ClassB's as one of its members (and an iterator).

ClassA also has a method to create new ClassB's (ie. using the new keyword) and store them in the vector, as well as a method to remove a ClassB from this vector.  And ClassA also has some function that will need to access a method from a ClassB object that is in the vector.

I've tried a few different ways, but I can't get the iterator to let me access a method of one of the vector objects.  I'm also not sure whether I'm adding the right thing to my vector.I  've read about doing this, checked some pages on Google where people were having similar troubles doing it properly, but still can't get shit to work.

I will post my crappy code if necessary.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List