Hi!
I'm working on a couple of classes and I'm wondering how I can use a normal member in my application class, where the member needs to use shared_from_this()?
Here is some code to clarify what I mean (see comments)
class Observable {
public:
void addObserver(boost::shared_ptr<Observer> observer) {
// add to a list
}
};
class Observer {
public:
virtual void onUpdate() = 0;
};
class MyObservableType : public Observable {
};
class ApplicationModel : public Observer {
private:
MyObservableType mot;
public:
void setup() {
// how do I pass this as a boost::shared_ptr, as ApplicationModel is not
// a boost::shared_ptr in the Application class this using a call to
// "shared_from_this()" (and inheriting public shared_from_this<ApplicationModel>
mot.addObserver([shared_from_this])
}
};
class Application {
private:
ApplicationModel model;
public:
void setup() {
model.
}
};