Difference b/w enum in C ans C++(C enums Vs C++ enums):
C Implementation Example
enum num
{
first ,
second ,
};
enum num urnum= first; //legal
enum num mynum = second; //legal
num urnum= first; //illegal
num mynum = second; //illegal
typedef enum colors
{
red,green,yellow
}COL;
colors mycolors = red; //illegal
colors urcolors = green; //illegal
colors ourcolors = yellow; //illegal
COL hiscolors = green; //legal
COL hercolors = yellow; //legal
enum COL hiscolors = green; //illegal
enum COL hercolors = yellow; //illegal
enum colors hiscolors = green; //legal
enum colors hercolors = yellow; //legal
hiscolors = 4; //legal
i = hiscolors; //legal
C++ Implementation Example
enum num
{
first ,
second ,
};
enum num urnum= first; //legal
enum num mynum = second; //legal
num urnum= first; //legal
num mynum = second; //legal
typedef enum colors
{
red,green,yellow
}COL;
colors mycolors = red; //Legal
colors urcolors = green; //Legal
colors ourcolors = yellow; //legal
COL hiscolors = green; //legal
COL hercolors = yellow; //legal
enum COL hiscolors = green; //illegal
enum COL hercolors = yellow; //illegal
enum colors hiscolors = green; //legal
enum colors hercolors = yellow; //legal
mycolors = 4; //illegal
int i = mycolors; //legal
Friday, November 7, 2008
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment