Improve example for ES.45

Fixes #895
pull/914/head
Jonathan Wakely 9 years ago
parent a96fed9c99
commit 32d6313607

@ -11076,9 +11076,11 @@ Unnamed constants embedded in expressions are easily overlooked and often hard t
No, we don't all know that there are 12 months, numbered 1..12, in a year. Better:
constexpr int month_count = 12; // months are numbered 1..12
// months are indexed 1..12
constexpr int first_month = 1;
constexpr int last_month = 12;
for (int m = first_month; m <= month_count; ++m) // better
for (int m = first_month; m <= last_month; ++m) // better
cout << month[m] << '\n';
Better still, don't expose constants:

Loading…
Cancel
Save