I had a problem managing object pointers in a vector pointer for keeping track of objects and accessing their functions in C++.
I made an Actor class which is the base class for other object
Code: Select all
class Actor
{
};
The Spaceship class has shoot() function
Code: Select all
class Spaceship : public Actor
{
public:
void shoot()
{
}
};
Code: Select all
vector<Actor*>*collections;
Spaceship* s = new Spaceship;
collections->push_back(s);
Code: Select all
(*collections)[0]->shoot();