[問題]螞蟻書範利一問 C程式設計藝術第五版
source code如下:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
enum months {
Jan=1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};
int _tmain(int argc, _TCHAR* argv[])
{
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%15s\n", month, monthName[month]);
}
return 0;
}
我翻了兩版的螞蟻書,都寫得一樣。可是...我實際操做出現error...
1>i:\project\enum_example_1\enum_example_1.cpp(19) : error C2676:
binary '++' : 'months' does not define this operator or
a conversion to a type acceptable to the predefined operatormonth++
問題出在month++這個用法不行...
所以是書打錯了嗎?????
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.118.199.117
→
04/29 16:19, , 1F
04/29 16:19, 1F
→
04/29 17:16, , 2F
04/29 17:16, 2F
→
04/29 21:47, , 3F
04/29 21:47, 3F
→
04/29 21:48, , 4F
04/29 21:48, 4F
→
04/29 21:55, , 5F
04/29 21:55, 5F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):