Coderiving

Karen Lanrap karen at digitaldaemon.com
Tue Nov 21 07:35:20 PST 2006


Why one can derive from a nested class only in the corresponding 
super class?

The example gives the error:
> super class Id is nested within Concept, not Concrete

But Concrete is derived from Concept and should contain the 
definition of the class Id!


<code>
interface Identifier
{
    char[] whoAmI();
}
class Concept
{
    class Id:Identifier
    {
        char[] whoAmI()
        {
            return "Concept.".dup;
        }
    }
}

class Concrete: Concept
{
    class Idl: Id  //does not work
    {
        char[] whoAmI(){
            return "Concrete.".dup;
        }
    }
}
void main()
{
    auto instance= new Concrete;
}
</code>




More information about the Digitalmars-d-learn mailing list