Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

interface

Part of KeywordsCategory

Purpose

To demonstrate using an interface.

Description

A simple example of a sophisticated abtraction tool.

Example

interface I
{
    void a();
    void b();
}

class Impl : I
{
    void a()
    {
    }

    void b()
    {
    }
}


class Kid : Impl
{
    void b()
    {
        printf("overriden method\n\0");
    }
}


void main()
{  
    Kid k = new Kid();
    k.b();
}

Source

Inspired by a newsgroup post (D:20956) by Hauke Duden.

More Information

More information is available in the D Specification.