enum

来源:互联网 发布:淘宝便宜苹果手机骗局 编辑:程序博客网 时间:2024/04/28 09:39
// enum is just like struct key wordenum week{sunday, monday, tuesday, wednesday, thirsday, friday, saturday, }; // extra comma in the end, but it is not necessaryint main(int argc, char* argv[]){cout<<sunday<<endl;cout<<monday<<endl;// cpp styleweek weekday;//weekday = 4;// fail,can't convert from 'int' to 'week'weekday = (week)4;// OKweekday = static_cast<week>(4);// OKint a = weekday;// OK, it is right to convert from 'week' to 'int'// c styleenum week weekday_1 = monday;// enum is just like struct between c and cppreturn 0;}


原创粉丝点击