D Programming Interfaces - D Programming Language

What is D Programming Interfaces?

An interface is a manner of forcing the lessons that inherit from it to have to implement positive functions or variables. features ought to no longer be applied at an interface due to the fact they're continually carried out within the training that inherit from the interface.

An interface has created the use of the interface keyword rather than the class keyword despite the fact that the 2 are similar in a number of methods. whilst you want to inherit from an interface and the class already inherits from another class then you want to split the call of the class and the call of the interface with a comma.

let us study a simple example that explains the usage of an interface.

Example

When the above code is compiled and executed, it produces the following result −

Interface with Final and Static Functions in D

An interface can have final and static method for which definitions should be included in interface itself. These functions cannot be overriden by the derived class. A simple example is shown below.

Example

When the above code is compiled and executed, it produces the following result −

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

D Programming Language Topics