Avoiding abstract

Oliver Ruebenkoenig oliver.ruebenkoenig at web.de
Wed May 30 10:56:02 PDT 2007


Hi everyone,

the following code does what i want. I was wondering if the same out put can be produced without having the abstract char [] rawSymName(); in the Expr class? Thanks for any hints and thoughts,

Oliver



import std.stdio;

Expr mySymbol;

public class Expr {
public
    abstract char [] rawSymName();
    abstract Expr head();
}


class Symbol : public Expr {
public 
    this( char [] name ) { 
        this.itsName = name;
    }   
    Expr head() { return mySymbol; }
    char [] rawSymName () {
        return this.itsName;
    }   
private
    char [] itsName;
}

int main( char [][] arg ) { 

    Expr myString;

    mySymbol = new Symbol("Symbol");
    myString = new Symbol("String");

    writefln(mySymbol.rawSymName() );
    writefln(mySymbol.head().rawSymName() );
    writefln(mySymbol.head().head().rawSymName() );

    writefln(myString.head().head().rawSymName() );
    
    return 0;
}



More information about the Digitalmars-d-learn mailing list