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;
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.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
lol like your example
thnks