Create a class that combines multiple interfaces

I have a C ++ class that can optionally support some additional functions (defined by abstract interfaces). There is a way in Microsoft COM to define a class for such functions using QueryInterface(GUID, void**). This requires reinterpret_cast for all interfaces for void *. My question is, is there a safer way to achieve the same without casting?

+3
source share
1 answer

COM has a requirement of receiving any interface from any other supported by the object. You do not need to live by this requirement. Just add getters to each interface that you expect to support.

struct IBase
{
    IMoreCapabilities * GetMoreCapabilities();
};
+3
source

All Articles