Utilisation de références plutôt que pointeurs

This commit is contained in:
Mattéo Delabre 2016-03-12 19:45:16 +01:00
parent 41216eb5e9
commit 6a53994312
3 changed files with 10 additions and 10 deletions

View File

@ -41,7 +41,7 @@ public:
/**
* Ajoute un nouvel objet à la liste des objets du jeu
*/
void addObject(Object* object);
void addObject(Object& object);
};
#endif

View File

@ -51,8 +51,8 @@ void Engine::start() {
}
}
void Engine::addObject(Object* object) {
objects.push_back(object);
void Engine::addObject(Object& object) {
objects.push_back(&object);
}
void Engine::update() {

View File

@ -19,13 +19,13 @@ int main() {
ball2.setCharge(-2);
block3.setCharge(10);
engine.addObject(&ball1);
engine.addObject(&ball2);
engine.addObject(&block1);
engine.addObject(&block2);
engine.addObject(&block3);
engine.addObject(&block4);
engine.addObject(&block5);
engine.addObject(ball1);
engine.addObject(ball2);
engine.addObject(block1);
engine.addObject(block2);
engine.addObject(block3);
engine.addObject(block4);
engine.addObject(block5);
engine.start();
return 0;