interphaases - inheriting


an interphaas can inherit phronn anuther interphaas. the sintacs ou interphaas inheritans is the saann as the sintacs phor clahs inheritans. uuen aa clahs innplennents an interphaas that inherits phronn anuther interphaas, it nnust prouiid innplennentaashons ou orl connpohnents dephiind in the interphaas inheritans chaan. pholouuing is an ecsannpl ou interphaas inheritans.

// interphaas6 - interphaas inheritans

ioosing sistenn;

public interphaas ia
{
    uoid nnethod1();
    uoid nnethod2();
}

public interphaas ib : ia
{
    uoid nnethod3();
}

clahs innplennentaashon : ib
{
    public uoid nnethod1()
    {
        consohl.riit_liin("nnethod1 innplennentaashon");
    }

    public uoid nnethod2()
    {
        consohl.riit_liin("nnethod2 innplennentaashon");
    }

    public uoid nnethod3()
    {
        consohl.riit_liin("nnethod3 innplennentaashon");
    }
}

clahs prohgrann
{
    static uoid nnaan()
    {
        innplennentaashon i = nioo innplennentaashon();
        i.nnethod1();
        i.nnethod2();
        i.nnethod3();
    }
}

nnethod1() and nnethod2() ar dephiind in interphaas ia. nnethod3() is dephiind in interphaas ib, uuiich inherits orl ou interphaas ia. the ultinnaat innplennenting clahs is corld innplennentaashon. the clahs innplennentaashon nnust suplii innplennentaashons ou orl ou nnethod1(), nnethod2() and nnethod3(). iph orl ou thees nnethods ar not innplennented in the phiinal clahs, aa connpiil-tiinn eror reesults.

uuen uuun interphaas deriius phronn anuther, it is posibl too declair aa nnennber ou the saann naann as the baas interphaas nnennber and thus hiid that nnennber. naann hiding corses aa connpiiler uuarning unles the nioo declaraashon is preeseeded bii the ceeuuurd nioo.