64,654
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
using namespace std;
typedef enum
{
student= 1,
worker,
teacher,
doctor
} Peopletype;
void main(void)
{
Peopletype a = static_cast<Peopletype>(2);
printf("%d",a);
}
#include <stdio.h>
typedef enum
{
student= 1,
worker,
teacher,
doctor
} Peopletype;
//现有一值为整数i,如何将它赋值给枚举型变量a,并用printf语句输出呢?
int main()
{
int i=2;
Peopletype a =Peopletype(i);
printf("%d\n",a);
}