For example the C++ classes
class Shape { public: void setPosition (long x, long y); protected: long x; long y; }; class Rect : public Shape { public: void setDimension (long width, long height); protected: long width; long height; };
expressed in COM, define an interface for each inheritance level:
class IShape : public FUnknown { public: virtual void setPosition (long x, long y) = 0; }; class IRect : public FUnknown { public: virtual void setDimension (long width, long height) = 0; };
In the next program version there need to be changes to the Shape class that look like this:
class Shape { public: void setPosition (long x, long y); void setColor (Color color); protected: long x; long y; Color color; };
The COM representation now reflect the changes to Shape by adding a new interface that inherits from IShape and looks like the following code, while the former interface definitions remain the same:
class IShape2 : public IShape { public: virtual void setColor (Color color) = 0; };