Originale-mail to me for new edition

 

Object interfaces

 

An object interface or simply interface defines methods that can be implemented by a class. Interfaces are declared like classes, but cannot be directly instantiated and do not have their own method definitions. Rather, it is the responsibility of any class that supports an interface to provide implementations for the interface’s methods. A variable of an interface type can reference an object whose class implements that interface; however, only methods declared in the interface can be called using such a variable.

Interfaces offer some of the advantages of multiple inheritance without the semantic difficulties. They are also essential for using distributed object models. Custom objects built that support interfaces can interact with objects written in C++, Java, and other languages.

 

Interface types

Implementing interfaces

Interface references

Automation objects

 

Topic groups

 

See also

Classes and objects: Overview

 

 

译文

 

对象接口

 

一个对象接口(object interface)或简单接口(simply interface)定义了若干方法,这些方法通过一个类来实现。接口象类一样被声明,但不能直接被实例化,也不能拥有其自身的方法定义。支持一个接口提供对接口方法的实现,这是所有类的职责所在。如果TSomeClass实现一个接口ISomeClass,那么类型为ISomeClass的变量V可以引用类型为TSomeClass的实例对象;然而,只有在接口中声明过的方法才能用变量V调用。

接口在多重继承方面提供了一些优势,而语义却较容易。接口实质上是使用分布式对象模块。基于支持接口建立的自定义对象可以与C++Java或其他语言编写的对象相互作用

 

接口类型

实现接口

接口引用

自动化对象

 

主题组

 

相关主题

类和对象:概述