Advertisement

Enumerated Constants

Started by April 13, 2002 10:40 AM
1 comment, last by Noxxid 22 years, 5 months ago
I keep getting errors in this program when I try to run it and I can''t seem to find what''s wrong. Thanks for any and all help.
  
#include <iostream.h>

int main()
{
 enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,  A_Saturday };
 Days DayOff;
 int x;

 cout << "What day would you like off (0-6)? ";
 cin >> x;
 DayOff = Days(x);

 if (Dayoff == Sunday || DayOff == Saturday)
    cout << "\nYou''re already off on weekends!\n";
 else
    cout << "\nOkay, I''ll put in the vacation day.\n";
 cin.get();
}
  
"Classes will dull your mind destroy the potential for authentic creativity"
choose between enumerated type A_Saturday and Saturday.
make sure you are consistent with variable names (you have DayOff in one place and Dayoff in another: choose one or the other, not both).
Advertisement
quote: if (Dayoff == Sunday || DayOff == Saturday)


Dayoff should be DayOff to keep consistent capitalization.

quote: enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, A_Saturday };


Looking back at that same line, you don''t have a "Saturday" declared, only "A_Saturday," which will cause a problem.

Lastly, you need to return an int at the end of your main(), since it''s declared int main(). So just put return 0; before your last closing brace.

"Don''t be afraid to dream, for out of such fragile things come miracles."

This topic is closed to new replies.

Advertisement