20.1 Interface declarations

原创 2006年05月31日 23:45:00
An interface-declaration is a type-declaration (§16.5) that declares a new
interface type.
interface-declaration:
attributesopt interface-modifiersopt interface identifier interface-baseopt
interface-body ;opt
An interface-declaration consists of an optional set of attributes (§24),
followed by an optional set of interfacemodifiers
(§20.1.1), followed by the keyword interface and an identifier that names
the interface, optionally
followed by an optional interface-base specification (§20.1.2), followed
by a interface-body (§20.1.3), optionally
followed by a semicolon.
20.1.1 Interface modifiers
An interface-declaration may optionally include a sequence of interface
modifiers:
interface-modifiers:
interface-modifier
interface-modifiers interface-modifier
interface-modifier:
new
public
protected
internal
private
It is a compile-time error for the same modifier to appear multiple times
in an interface declaration.
The new modifier is only permitted on nested interfaces. It specifies that
the interface hides an inherited member
by the same name, as described in §17.2.2.
The public, protected, internal, and private modifiers control the
accessibility of the interface.
Depending on the context in which the interface declaration occurs, only
some of these modifiers may be
permitted (§10.5.1).
20.1.2 Base interfaces
An interface can inherit from zero or more interfaces, which are called the
explicit base interfaces of the
interface. When an interface has one or more explicit base interfaces, then
in the declaration of that interface, the
interface identifier is followed by a colon and a comma-separated list of
base interface identifiers.
interface-base:
: interface-type-list
The explicit base interfaces of an interface must be at least as accessible
as the interface itself (§10.5.4). [Note:
For example, it is a compile-time error to specify a private or internal
interface in the interface-base of a
public interface. end note]
C# LANGUAGE SPECIFICATION
280
It is a compile-time error for an interface to directly or indirectly
inherit from itself.
The base interfaces of an interface are the explicit base interfaces and
their base interfaces. In other words, the
set of base interfaces is the complete transitive closure of the explicit
base interfaces, their explicit base
interfaces, and so on. An interface inherits all members of its base
interfaces. [Example: In the example
interface IControl
{
void Paint();
}
interface ITextBox: IControl
{
void SetText(string text);
}
interface IListBox: IControl
{
void SetItems(string[] items);
}
interface IComboBox: ITextBox, IListBox {}
the base interfaces of IComboBox are IControl, ITextBox, and IListBox. In
other words, the IComboBox
interface above inherits members SetText and SetItems as well as Paint. end
example]
A class or struct that implements an interface also implicitly implements
all of the interface?s base interfaces.
20.1.3 Interface body
The interface-body of an interface defines the members of the interface.
interface-body:
{ interface-member-declarationsopt }
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

黑马程序员——20.1,IO流,FileWriter,FileReader

------Java培训、Android培训、iOS培训、.Net培训、期待与您交流! -------                  &...

整合SiteMesh 之 20.1 调整应用的风格

20.1  调整应用的风格 对于一个企业级的Web应用而言,页面展示需要有统一的风格,比如统一的配色、页头显示企业LOGO、页脚显示版权信息等等。在实际的开发中应该怎么做呢? 统一的配色可以通过引...

20.1 广播接收器案例

  • 2015-09-06 16:13
  • 649KB
  • 下载

<Effective Mordern C++>笔记:Item 9:prefer alias declarations to typedefs.

转载自原博:原博 C++11中引入的std::unique_ptr智能指针是个好用的东西,在我们使用unique_ptr的时候往往会写出这样的类型std::uniqeu_ptr<std::unorde...

CF20.1显刀器免惠版

  • 2008-09-12 22:10
  • 17.23MB
  • 下载

学习笔记一:命名空间(namespace)之四:using declarations和using directives的区别

(本文主要参考c++ primer第17章2.4节内容。) 由前面内容,我们知道c++引入命名空间(namespace)概念的主要目的是避免命名冲突。但是当我们想要引用命名空间成员时,我们就会体会到...

WealshBrowser V20.1 (源码)

  • 2006-01-13 09:51
  • 630KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)