Interface (object-oriented programming)In object-oriented programming, an interface or protocol type[a] is a data type that acts as an abstraction of a class. It describes a set of method signatures, the implementations of which may be provided by multiple classes that are otherwise not necessarily related to each other.[1] A class which provides the methods listed in an interface is said to implement the interface,[1] or to adopt the protocol.[2] If objects are fully encapsulated then the interface is the only way in which they may be accessed by other objects. For example, in Java, the Some programming languages provide explicit language support for interfaces: Ada, C#, D, Dart, Delphi, Go, Java, Logtalk, Object Pascal, Objective-C, OCaml, PHP, Racket, Seed7, Swift, Python 3.8. In languages supporting multiple inheritance, such as C++, interfaces are implemented as abstract classes. In languages without explicit support, interfaces are often still present as conventions; this is known as duck typing. For example, in Python, any class can implement an Type classes in languages like Haskell, or module signatures in ML and OCaml, are used for many of the things that interfaces are used for.[clarification needed] In Rust, interfaces are called traits.[4] See also
Notes
References
|
Portal di Ensiklopedia Dunia