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.
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
interface-modifiers interface-modifier
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-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]
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
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-member-declarationsopt }

Definitions and Declarations (C++) dllimport dllexport

Definitions and Declarations (C++) Microsoft Specific The DLL interfac...
  • sepnineth
  • sepnineth
  • 2014年02月14日 09:47
  • 643

ISO C89 forbids mixed declarations and code

ISO C90 forbids mixed declarations and code     应在写任何代码之前先进行声明。不要将声明和代码混合在一起。...
  • nemo2011
  • nemo2011
  • 2012年03月17日 10:28
  • 1338

flex4 -- fx:Declarations

fx下放置了顶级包的内容。如数据类型、全局函数和全局常量等。 在flex3里这样写是合法的:,但在Gumbo中却是不行的,正确做法需要用到来申明,比如: 100 ...
  • ld_flex
  • ld_flex
  • 2012年03月14日 17:41
  • 3631

dhcpd 一个警告信息的解决方法

dhcp配置中经常会看到如下的警告信息:dhcpd: WARNING: Host declarations are global.  They are not limited to the scope...
  • lhfeng
  • lhfeng
  • 2010年10月29日 16:40
  • 2654

warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]

  • sfe1012
  • sfe1012
  • 2017年07月25日 08:53
  • 252

webStorm报错Import declarations are not supported by current JavaScript version

首先贴出报错信息,在webStorm编辑器上的报错: Import declarations are not supported by current JavaScript version. ...
  • SpicyBoiledFish
  • SpicyBoiledFish
  • 2017年08月18日 14:46
  • 4770

Variable Declarations

Scala allows you to decide whether a variable is immutable (read-only) or not (readwrite) when you d...
  • qq_16912257
  • qq_16912257
  • 2016年10月05日 17:08
  • 164

linux gcc编译错误:‘for’ loop initial declarations are only allowed in C99 mode

linux系统下的c编程与windows有所不同,如果你在用gcc编译代码的时候提示‘for’ loop initial declarations are only allowed in C99 ...
  • zhangmuyan
  • zhangmuyan
  • 2012年04月09日 19:35
  • 6244

java.sql.SQLException: ORA-06553: PLS-307: too many declarations of 'GET_PROFILE_VALUE' match this call

Problem: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation.  Statement:...
  • qingqingxuelang
  • qingqingxuelang
  • 2010年05月18日 13:28
  • 3608

ISO C90 forbids mixed declarations and code[-Wdeclaration-after-statement]

ISO C90 forbids mixed declarations and code[-Wdeclaration-after-statement]
  • yanlaifan
  • yanlaifan
  • 2016年04月23日 13:01
  • 2509
您举报文章:20.1 Interface declarations