Monday, March 2, 2009

valid and invalid enum declarations



valid enum declarations:
enum Beer
{
KF, RC;
}

enum Beer
{
KF, RC;
int price; //valid
}

enum Month
{
Jan,Feb,JAN; //valid, due to case sensitive jan!=JAN
}

class Ordinary
{
public enum Dir{North,South,East}
}

in-valid enum declarations:
enum Beer
{
KF, RC //invalid ; missing
int price;
}
enum Beer
{
int price; //invalid 1st statment should be enum constants.
KF, RC;
}

enum Month
{
Jan,Feb,Jan; //invalid,error:Jan already defined
}



0 comments:

Post a Comment