Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.
Version 1 (modified by jcc7, 18 years ago)
--

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();
}

More Information

Inspired by a newsgroup post by Hauke Duden.

More information is available in the D Specification.

Source

Link http://www.dsource.org/tutorials/index.php?show_example=45
Posted by jcc7
Date/Time Sat Oct 30, 2004 3:26 pm