Links

Categories

Tags


« | Main | »

Hybrid classes

By Jewe | October 29, 2012

strict interface IPerson
{
    method string GetName();
    method SetName(string name);
}

class Person : IPerson
{
    string name;
    method Person() { name = "Adam"; }
    method string GetName() { return name; }
    method SetName(string s) { name = s; }
}

class NewPerson : IPerson hybrid Person
{
    method NewPerson() hybrid (new Person())
    {
    }
    method SetName(string s)
    {
        // do something
        println("NewPerson::SetName = " + s);
        // then call base
        base.SetName(s);
    }
}

Topics: code examples | Comments Off on Hybrid classes

Comments are closed.