I have an interface like this
class IVersion
{
public:
virtual char * get_version() const = 0;
virtual bool is_compatible(const IVersion& other) const = 0;
};
I have a set of "Device" classes, all of which need to have the above interface supported on them so that I can check for compatibility between devices. For doing so I publicly inherit each device from the above IVersion class.
Now since I am inheriting from a IVersion(and from Liskov Substitution Principle), it implies that a device is a Version. But the actual relationship that I want is that a device has a version.
I want all devices to support methods as in IVersion, but the way I have done it I think, is not correct. Can anyone suggest a better way? I can use composition, but then I will need to add methods now in IVersion, into the device base class and then internally use an IDevice implementation. Is this the best way to do what I want to achieve?
IVersioned, thus "a device is versioned". - Iridium