In the book C++ Primer Plus third edition they use enum to create a symbolic constant
ie
enum {Q_SIZE=10};
why dont they do this instead?
const int Q_SIZE=10;
Printable View
In the book C++ Primer Plus third edition they use enum to create a symbolic constant
ie
enum {Q_SIZE=10};
why dont they do this instead?
const int Q_SIZE=10;
There is no good reason for using an enum in that example...
a better example of using enums might be:
enum Weight { light, normal, heavy };
....
if(p1.userMeasure< 120) p1.userWeight = light;
else
if(p1.userMeasure < 170) p1.userWeight = normal;
else
p1.userWeight = normal;
...
if(p1.userWeight == heavy)
cout << "My how bout some slim-fast?" << endl;
...etc.
lol like your example
thnks