jeudi 20 juin 2019

Shared pointer using (this) registering to an observer

I am having a problem trying to use a shared pointer from a class that wants to register to an observer (using ) here is the example.

Observer.hpp

class Observer {
virtual void update() = 0;
}

Consumer.hpp

class Consumer : public Observer {
virtual void update() override;
}

Consumer.cpp

class Consumer {
***

THIS IS NOT WORKING - How to do it using shared pointers??


register.registerObserver(std::make_shared<Observer>(this));
}

Register.cpp

class Register {
void registerObserver(const std::shared_ptr<Observer>& observer);
}

Aucun commentaire:

Enregistrer un commentaire