I try to instantiate my class A (its goal is to notify other classes observers by a result ) into class B and after adding the observers the class A call its destructor and delete these observers . What I want is to instantiate my class A into class B without invoking the destructor. I think about a handler class which will be singleton but nothing is clear in my mind. Please help me. I code with c++.
My code looks like this:
Class A{
A(){addListeners()}
~A(){deleteListeners()}
};
and
Class B{
B()
};
and out of the declaration of B I introduce a method configure that returns an instance of B.
shared_ptr<B> configureB(){
A = new A(); B->notifyListeners()
}
Aucun commentaire:
Enregistrer un commentaire