Lec21 Enum
Lec21 Enum
Structured Data
11-3
Copyright © 2012 Pearson Education, Inc.
Accessing Structure Members
via Pointer Variables
• Must use () to dereference pointer
variable, not field within structure:
cout << (*stuPtr).studentID;
11-4
Copyright © 2012 Pearson Education, Inc.
From Program 11-8
Day workDay;
workDay = WEDNESDAY;
0 2 4
Copyright © 2012 Pearson Education, Inc.
Assigning an integer to an enum
Variable
• You cannot directly assign an integer value
to an enum variable. This will not work:
workDay = 3; // Error!
• Instead, you must cast the integer:
workDay = static_cast<Day>(3);
int x;
x = THURSDAY;