views:

170

answers:

1

I am working with some legacy c++ code and I need to extend an interface. The current interfaces are for example:

[
  object,
  uuid(guid),
  version(1.0),
  dual,
  nonextensible,
  oleautomation
]
interface IInfo : ITask {
   // Methods here
}

[
  object,
  uuid(guid),
  version(1.0),
  dual,
  nonextensible,
  oleautomation
]
interface IExtendedInfoTask : IInfo {
   // Methods here
}

What I would like to extend is the IInfo interface. Now from my understanding the proper way to do this would be to create an IInfo2 interface that inherits the IInfo interface, however I need my IExtendedInfoTask to inherit from this IInfo2. Changing its current inheritance would break the existing interface would it not?

Would the proper way to do this be creating a IExtendedInfoTask that extends the IInfo2 and duplicate the methods of the IExtendedInfoTask?

+6  A: 

The proper way to do this is to create an IExtendedInfoTask2 that extends the new IInfo2 interface. COM requires that an interface, once defined, is immutable.

You can have the same class implement both IExtendedInfoTask and IExtendedInfoTask2, so the caller can use either version. It's only a vtable difference -- you don't have to implement the methods separately.

Tadmas
Perfect, thanks!
Zenox