How do you declare an interface in C++?

前端 未结 15 3103
借酒劲吻你
借酒劲吻你 2020-11-22 03:26

How do I setup a class that represents an interface? Is this just an abstract base class?

15条回答
  •  梦谈多话
    2020-11-22 04:04

    I'm still new in C++ development. I started with Visual Studio (VS).

    Yet, no one seems to mentioned the __interface in VS (.NET). I am not very sure if this is a good way to declare an interface. But it seems to provide an additional enforcement (mentioned in the documents). Such that you don't have to explicitly specify the virtual TYPE Method() = 0;, since it will be automatically converted.

    __interface IMyInterface {
       HRESULT CommitX();
       HRESULT get_X(BSTR* pbstrName);
    };
    

    However, I don't use it because I am concern about the cross platform compilation compatibility, since it only available under .NET.

    If anyone do have anything interesting about it, please share. :-)

    Thanks.

提交回复
热议问题