Original Post
I''m writing a set of classes where the base class is an interface which declares a number of overloaded functions - that is,
Enginuity1 | Enginuity2 | Enginuity3 | Enginuity4 ry. .ibu cy. .abu ry. dy. "sy. .ubu py. .ebu ry. py. .ibu gy." fy. .ibu ny. .ebu
class ISerializer
{
virtual void IO(int &val)=0;
virtual void IO(float &val)=0;
virtual void IO(std::string &val)=0;
};
and so on. I then publicly derive from that class (e.g. ''class CSerialSaver : public ISerializer''), implement the virtual functions, and all seems to work.
However, I want to be able to augment the system to add extra overloads - IO(long &val) for example - without changing the existing classes.
So, what I thought I could do is this:
class ISerializerExtender : virtual public ISerializer
{
virtual void IO(long &val)=0;
virtual void IO(someOtherType &val)=0;
};
and *then,* derive objects from both that and the original concrete classes (so, ''class CExtendedSerialSaver : public ISerializerExtender, CSerialSaver''), implement the new overloads, and then it all be peachy. Then when I''m passing the extended objects around I use a pointer to ISerializerExtender rather than ISerializer.
My question is, will this work, and have I set up the virtual base classes properly? I''m wondering if the CSerialSaver-level classes need to have ISerializer as virtual as well.
Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.Enginuity1 | Enginuity2 | Enginuity3 | Enginuity4 ry. .ibu cy. .abu ry. dy. "sy. .ubu py. .ebu ry. py. .ibu gy." fy. .ibu ny. .ebu