c++ - error use of enum without previous declaration? -
i'm learning c++ book , following example doesn't work in codeblocks. compiler gives error:
use of enum
'days'without previous declaration
can enlight me here?
#include <iostream> using namespace std; int main() // main routine { int a; enum days (zo,ma,di,wo,do,vr,za); // <error here> : use of enum 'days' without previous declaration days today; today = ma; if (today == zo || today == za) cout << "weekend \n" else cout << "ohno workday \n"; return 0; }
you're using enum incorrectly. parentheses should braces:
enum days {zo,ma,di,wo,do,vr,za}; now zo equal 0, since didn't explicitly define value, , each thereafter 1 more last.
also notice (easily, due syntax highlighting) do conflicts do keyword reserved do...while statements.
Comments
Post a Comment