enum Days { Sunday, Monday, Tuesday, Wednesday,Thursday, Friday, Saturday };
for( Days d = Sunday; d < Saturday; ++d )
cout << "d is: " << d << endl;
C++ won't know how to increment d unless we define how that operator works for the type Days. Overload operator ++ so this "for" loop compiles and runs correctly.
day &operator++(day &d) {
d = (day)(d + 1);
return d;
}
i wrote this is this correct