Basic COM  «Prev 

COM interface properties

Defining COM interface

The following code declares a C++ class that, when instantiated, implements a COM interface called IMyComInterface:

class CIMyComInterface {

 //For C++ we usually add
 //a 'C' in front of the
 //interface name

    virtual HRESULT __stdcall QueryInterface
 (const IID& iid, void **ppv);
 
    virtual unsigned long __stdcall AddRef();
    virtual unsigned long __stdcall Release();

    virtual HRESULT __stdcall Fx1(CHAR *buf);
    virtual HRESULT __stdcall Fx2();
};


When a pointer to this class is passed to a COM client, the client can't see any part of the object other than the vtable.
Data and nonvirtual member functions are not visible or accessible.