码迷,mamicode.com
首页 > 其他好文 > 详细

3.10 枚举型常量

时间:2015-05-20 14:44:18      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

枚举型常量用enum来定义

enum num{zero,one,two,three,four};

例子:

#include<iostream>
using namespace std;
int main(){
    enum day
    {
        sunday,monday,tuesday,wednesday,thursday,friday,saturday
    };
    day today;
    today = monday;
    today = sunday;
    if (today == sunday || today == saturday){
        cout << "周末休息";
    }
    else{
        cout << "工作日";
    }
    return 0;
}

 

3.10 枚举型常量

标签:

原文地址:http://www.cnblogs.com/cplusplus-study/p/4517049.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!