Okay so basically I've got a vector, thePointerTest, that is holding pointers to pointerTest objects. What I need to know is how to call the print function for a printerTest object pointer while it is in the vector.
vector<pointerTest*> thePointerTest; ==> the vector
So how would I call the pointerTest.print(); function while the pointer is still in the vector?
What I have right now is
thePointerTest[count]->print();
While this compiles correctly, whenever I try to run the program it crashes after the line of code before this command, and before any information can be printed to the screen.
After checking I know that the pointerTest objects are being created I just can't figure out how to call a function for one from a pointer in a vector.
The pointers will be invalidated after each for loop is over (because the object they point to is destructed). Instead, you should allocate them with new (just don't forget to delete them).