[問題] 關於enum一問...??
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
dev-c
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
餵入的資料(Input):
照著書本範例打...
enum color{
red,
green,
blue
}shirt;
將shirt = 1; //會出現錯誤!!
或是char color;
scanf("%c",&color);
shirt = color; //也會出現相同的錯誤!!
錯誤碼:
invalid conversion from int to main()::color
invalid conversion from char to main()::color'
照理說...
不是能將enum變數設成整數嗎?? 不應出錯???
請問是我編譯器哪邊動到了嗎??
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.141.244.126
→
10/10 16:44, , 1F
10/10 16:44, 1F
→
10/10 16:48, , 2F
10/10 16:48, 2F
→
10/10 16:56, , 3F
10/10 16:56, 3F
→
10/10 16:57, , 4F
10/10 16:57, 4F
→
10/10 17:04, , 5F
10/10 17:04, 5F
→
10/10 17:05, , 6F
10/10 17:05, 6F
→
10/10 17:15, , 7F
10/10 17:15, 7F
推
10/10 19:22, , 8F
10/10 19:22, 8F
→
10/10 21:04, , 9F
10/10 21:04, 9F
→
10/10 21:05, , 10F
10/10 21:05, 10F
→
10/10 22:07, , 11F
10/10 22:07, 11F
→
10/10 23:07, , 12F
10/10 23:07, 12F