Re: Is there any problem with customizing a new interface out of
other interfaces?
On Sep 1, 11:07 pm, DeMarcus <use_my_alias_h...@hotmail.com> wrote:
Let's say I want to create a function that can take all kinds of
objects, but with the constraint that they must at least be clonable and
be able to do some work. Is the following still a bad idea?
class IConstrainedObject : public ICloner, public IWorker
{
public:
virtual ~IConstrainedObject() {}
};
void someFunction( IConstrainedObject* object ) { /* ... */ }
I guess the deciding factor clincher is how _important_ is this
constraint in the overall design.
Note, however, that with interfaces, you don't normally have a
destructor at all, let alone a virtual one. You're using mix-in
inheritance anyhow, so the deriving concrete object's destructor is
what matters. (In fact, is there any reason/situation where what I am
saying is wrong? Anyone?)
Also, should someFunction check for null object? I guess it should
not, and so you should have IConstrainedObject& (not*) there. ;-)
Goran.