C++的数据类型分为两类:
基本数据类型---
整形
字符型
实型(浮点型)
逻辑型(布尔型)
非基本数据类型(用户定义的数据类型)----
数组
指针
空类型
结构
联合
枚举
类
void main()
{
for(int i=1;i<=50;i++)
{
for(int j=1;j<10;j++)
if(i*j==50)
goto end;
}
end:
cout<<(i*j)<//为什么报j未定义
}
//为什么下面这样就好了呢
void main()
{
int i,j;
for(i=1;i<=50;i++)
{
for(j=1;j<10;j++)
if(i*j==50)
goto end;
}
end:
cout<<(i*j)<}
//enum
enum weekday {sun,mon,tue,wed,thu,fri,sat};
1.对枚举元素按照常量处理,不能对他们赋值。例如不能写成:sun=0;
2.枚举元素具有缺省值,他们依次是:0,1,2,3,4.......
3.也可在声明时另行指定元素的值 如:enum weekday {sun=7,mon=1,tue,wed,thu,fri,sat};
4.枚举值可以进行关系运算
5.整数值不能直接赋给枚举变量,如需要将整型值赋给枚举变量,应进行强制类型转换
typedef enum enumAKWapFont
{
AKWapFontNormal = 0x00, /**< render normally */
AKWapFontBig = 0x01, /**< render with a bigger font */
AKWapFontSmall = 0x02 /**< render with a smaller font */
}AKWapFont;
typedef struct tagAKWapStyleData
{
AKWapFont font; /**< WAP page element font, refer to AKWapFont*/
T_U8 style; /**< WAP page element style, can be a combination of AKWAPStyle enum values, refer to AKWapStyle*/
}AKWapStyleData;
static T_U8 WapExplorer_IAKWapDispContext_GetStyleFont(
IAKWapDispContext *dispCtx,
AKWapStyleData *styleData);
static T_U8 WapExplorer_IAKWapDispContext_GetStyleFont(IAKWapDispContext *dispCtx, AKWapStyleData *styleData)
{
if(AKWapFontBig == styleData->font)
{
return WAP_FONT_BIG;
}
else if(AKWapFontSmall == styleData->font)
{
return WAP_FONT_SMALL;
}
return WAP_FONT_NORMAL;
}
//teaching example
#include
enum game_result{WIN,LOSE,TIE,CANCEL};
int main()
{
game_result result;
game_result omit=CANCEL;
int count;
for (count=WIN;count<=CANCEL;count++)
{
result=(game_result)count;
if(result==omit)
cout<<"the game was canceled"< else
{
cout<<"the game was played"< if(result==WIN)
cout<<"and we win"< if(result==LOSE)
cout<<"and we lost"< }
}
return 0;
}
阅读(745) | 评论(0) | 转发(0) |