R
Roman Werpachowski
I'm trying to do something like that: define class A, which contains a
handle to the object O of class B and calls this object's member
functions. I'd like the object O to be sort of a "plugin", so that
instead of class B a class inherited from it can be substituted, that
the object O can be swapped for a different one during the lifetime of
the object of class A. So far, I've implemented it like that:
class A {
private:
B * ptrB_;
}
and added the usual set of get/set routines (they return/accept a const
B& reference), Bptr_ is set to NULL in the constructor of A. I am not
satisfied with this solution, for obvious reasons. But I can't come
with anything better which would allow so much flexibility. Any
suggestions?
handle to the object O of class B and calls this object's member
functions. I'd like the object O to be sort of a "plugin", so that
instead of class B a class inherited from it can be substituted, that
the object O can be swapped for a different one during the lifetime of
the object of class A. So far, I've implemented it like that:
class A {
private:
B * ptrB_;
}
and added the usual set of get/set routines (they return/accept a const
B& reference), Bptr_ is set to NULL in the constructor of A. I am not
satisfied with this solution, for obvious reasons. But I can't come
with anything better which would allow so much flexibility. Any
suggestions?