Avoiding abstract

Jarrett Billingsley kb3ctd2 at yahoo.com
Wed May 30 11:13:50 PDT 2007


"Oliver Ruebenkoenig" <oliver.ruebenkoenig at web.de> wrote in message 
news:f3kdri$ap4$1 at digitalmars.com...
> 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

Why do you want to avoid abstract?

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

By the way, writing a protection attribute without a colon after it will 
only affect the immediately-following declaration.  So the public in this 
class only affects "this".  head and rawSymName are public but only because 
the default protection is public.  Similarly private only affects itsName; 
if you were to add other members after itsName, they would be public.  It 
looks like you want:

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




More information about the Digitalmars-d-learn mailing list