标题:枚举型自加运算问题求解
取消只看楼主
leepro
Rank: 2
等 级:论坛游民
帖 子:25
专家分:37
注 册:2009-10-23
结帖率:83.33%
已结贴  问题点数:10 回复次数:3 
枚举型自加运算问题求解
哪位大哥帮忙找一下下面程序的错误:
我调试时提示:
错误    2    error C2676: binary '++' : 'wmain::color' does not define this operator or a conversion to a type acceptable to the predefined operator    c:\documents and settings\颩,無心\my documents\visual studio 2005\projects\enum\enum\enum.cpp    15   


这是个枚举型的例子,书上说枚举型可以自加运算,但这儿却出错;我用的VS2005调试的;好像VC6.0也是同样的错误;


#include "stdafx.h"
#define n "%-10s"

void main()
{
    enum color{red,yellow,blue,white,black};
    enum color i,j,l,pri;
    int m,loop;
    m=0;
    for(i=red;i<=black;i++)
        for(j=red;j<=black;j++)
            if(i!=j)
                for(l=red;l<=black;l++)
                    if((l!=i)&&(l!=j))
                    {
                        m=m+1;
                        printf("%-4d",m);
                        for(loop=1;loop<=3;loop++)
                        {
                            switch(loop)
                            {case 1:pri=i;break;
                            case 2:pri=j;break;
                            case 3:pri=l;break;}
                            switch(pri)
                            {
                            case red:printf(n,"red");break;
                            case yellow:printf(n,"yellow");break;
                            case blue:printf(n,"blue");break;
                            case white:printf(n,"white");break;
                            case black:printf(n,"white");break;
                            }
                        }
                        printf("\n");
                    }
}
搜索更多相关主题的帖子: 问题求解 运算 枚举 
2009-11-24 13:39
leepro
Rank: 2
等 级:论坛游民
帖 子:25
专家分:37
注 册:2009-10-23
得分:0 
还是不行,同样的错误,好像是关于枚举型自增运算的问题
2009-11-24 18:18
leepro
Rank: 2
等 级:论坛游民
帖 子:25
专家分:37
注 册:2009-10-23
得分:0 
用vc6.0也不行吗?我用VC6.0也不行,同样的错误,当然头文件改成#include"stdio.h"了。
2009-11-24 23:01
leepro
Rank: 2
等 级:论坛游民
帖 子:25
专家分:37
注 册:2009-10-23
得分:0 
谁能帮我解释一下提示错误的意思吗:
错误    2    error C2676: binary '++' : 'wmain::color' does not define this operator or a conversion to a type acceptable to the predefined operator
2009-11-24 23:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-293213-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.690169 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved