enum for beginners

Johannes Totz johannes at jo-t.de
Mon Nov 14 14:25:09 PST 2011


Hi!

I'm having trouble with named typed enums.
This works (unnamed):

enum : string
{
   a = "a",
   b = "b"
}

int main(string[] argv)
{
   writeln(a);
   return 0;
}


But this does not:

enum X : string
{
   a = "a",  // Error: Integer constant expression expected
             //  instead of "a"
   b = "b"   // Error: Integer constant expression expected
             //  instead of "b"
}

int main(string[] argv)
{
   writeln(X.a);
   return 0;
}


What did I miss?


Johannes


More information about the Digitalmars-d-learn mailing list