declaration with typedef

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Dec 27 06:11:45 PST 2010


That's because you're creating a new type with typedef, and writeln()
doesn't know how to work with a "number" type. Use an alias:

void main()
{
   alias int number;
   number x;
   x = 314;
   writeln(x);
}

AFAIK typedef is scheduled for deprecation in D2 (if that's what you're using).

On 12/27/10, Hamad Mohammad <h.battel at hotmail.com> wrote:
> I can't compile this code
>
> void main()
> {
>     typedef int number;
>     number x;
>     x = 314;
>     writeln(x);
> }
>
>


More information about the Digitalmars-d-learn mailing list