My program doesn't have bugs. It just develops random features.
Interfaces that don't have any member declarations are called marker interfaces because they do nothing else but marking the implementing class. In Java this concept is used e.g. to specify whether list implementations support fast access in random order. In UnrealScript, empty interfaces are not always just marker interfaces. The otherwise empty interface classes in UT3 and UDK are all declared as "native" and thus contain logic or definitions declared in native C++ code.
|Please help improve this article or section by expanding it.|
Interface classes start with an interface declaration:
interface InterfaceName [extends ParentInterface] [modifiers];
The extends clause is optional for interface classes. If omitted, the interface extends class Interface. The Interface class itself conceptually extends class Object, but should actually be seen as independent from the class tree. A within clause is not allowed for interface declarations.
- The interface should be compiled after the specified classes or interfaces. This can be used to ensure struct and enum types used as parameter or return types in function declarations are already known to the compiler. It is only necessary if the class or interface is in the same package as this interface.
- The interface contains additional logic or definitions in native C++ code.
Interfaces can declare functions, structs and enums. The functions they declare should not have a body because they cannot be called anyway. Variable declarations are not allowed in interfaces and would not make any sense, if you think about it.
Interfaces can be implemented in any class by including the modifier
implements(InterfaceName) in the class declaration. The compiler will make sure the class correctly implements all functions specified by the interface. Instances of that class or any of its subclasses can be assigned to variables of type InterfaceName. Functions defined in the interface can be called on any object assigned to such a variable.
|Declarations||Preprocessor • Classes • Interfaces • Cpptext • Constants • Enums • Structs • Variables (Metadata) • Replication block • Operators • Delegates • Functions • States • Defaultproperties (Subobjects)|
|Types||bool • byte • float • int • name • string • Object • Class • Enums • Structs (Vector ⋅ Rotator ⋅ Quat ⋅ Color) • Static arrays • Dynamic arrays • Delegates • Typecasting|
|Literals||Boolean • Float • Integer • Names • Objects (None ⋅ Self) • Vectors • Rotators • Strings|
|Flow||GoTo • If • Assert • Return • Stop • Switch • While • Do...Until • For • ForEach • Break • Continue|
|Specifiers||Super • Global • Static • Default • Const|
|UnrealScript||Syntax • .UC • .UCI • .UPKG • Comments • #directives • Native|