|
-
March 26th, 2012, 11:04 PM
#1
Problem with enum
I am trying to run an example from a book I read.
"
#include <stdio.h>
enum months { Jan,Feb,Mar,Apr,Jun,Jul,Aug,Sep,Oct,Nov,Dec};
int main()
{
enum months month;
const char* monthName[]= { "","January","February","March","April","May","June","July","August","September","October","November","December"};
for (month=Jan;month<=Dec;month++)
printf("%2d%11s\n",month,monthName[month]);
return 0;
}
"
This code gives these errors:
main.cpp:35: error: no 'operator++(int)' declared for postfix '++', trying prefix operator instead
main.cpp:35: error: no match for 'operator++' in '++month'
Like you see "month++" in for loop's beginning gives the error but in the book it is written as that...
Last edited by AwArEnEsS; March 26th, 2012 at 11:15 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|