Call function from object instantiated in one class in another
Posted
by
Dk43
on Stack Overflow
See other posts from Stack Overflow
or by Dk43
Published on 2011-01-13T05:44:22Z
Indexed on
2011/01/13
5:53 UTC
Read the original article
Hit count: 166
c++
I have two classes, both of which need to be able to call the same instance of entitymanager
class Engine
{
EntityManager::Entitymanager EManager;
}
And I need to add an object to a vector contained by this particular instance of Engine. What I want to do is be able to add a bullet spawned by the player to the vector that contains all my entities.
class Player : Entity
{
void SpawnBullet() {Engine::EManager.Add(BULLET);}
}
The above returns this error:
error: object missing in reference to ‘Engine::EManager’
How do I resolve this? Any help or pointers in the right direction would be much appreciated!
© Stack Overflow or respective owner