*******************************interface是怎么回事?**********************************

关门兔 2002-12-04 02:43:53
我看到了这样的代码:
interface aaa
{
virtual bbb() = 0;
};

class ccc : public aaa
{
};

问题:
1,interface是C++的吗?怎么用?
2,interface或从interface继承来的类,不用声明析构函数为virtual吗?
...全文
59 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
关门兔 2002-12-12
  • 打赏
  • 举报
回复
真的没人知道吗?
DouDouBug 2002-12-04
  • 打赏
  • 举报
回复
#define interface struct
一个结构定义而已
Rocken 2002-12-04
  • 打赏
  • 举报
回复
看来这个东东是微软为了com编程而自定义出来的
关门兔 2002-12-04
  • 打赏
  • 举报
回复
在DDK中看到了这个:
#define interface struct
KennyYuan 2002-12-04
  • 打赏
  • 举报
回复
c#有interface,C++里是带下划线的
KennyYuan 2002-12-04
  • 打赏
  • 举报
回复
C++ Language Reference

__interfaceSee Also
C++ Keywords | Interface Attributes
Microsoft Specific

A Visual C++ interface can be defined as follows:

Can inherit from zero or more base interfaces.
Cannot inherit from a base class.
Can only contain public, pure virtual methods.
Cannot contain constructors, destructors, or operators.
Cannot contain static methods.
Cannot contain data members; properties are allowed.
modifier __interface interface-name {interface-definition}
A C++ class or struct could be implemented with these rules, but __interface enforces them.

For example, the following is a sample interface definition:

__interface IMyInterface
{
HRESULT CommitX();
HRESULT get_X(BSTR* pbstrName);
};
Notice that you do not have to explicitly indicate that the CommitX and get_X functions are pure virtual. An equivalent declaration for the first function would be:

virtual HRESULT CommitX() = 0;
It is possible to define a managed interface. For example,

__gc __interface IMyInterface
{
};

Only managed classes can implement managed interfaces. See __gc for more information.

__interface implies the novtable __declspec modifier.

For more information about interfaces, see 6 gc Interfaces.

END Microsoft Specific

关门兔 2002-12-04
  • 打赏
  • 举报
回复
但我是在VC DLL程序中看到的。
不讨论JAVA的INTERFACE,否则我就贴到JAVA版了。
我想知道它是标准C++的,还是微软的?好象C++里没有INTERFACE的概念。
KennyYuan 2002-12-04
  • 打赏
  • 举报
回复
Java

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧