循环枚举定义是一种在编程中定义一组有限且固定的值的方法。以下是创建循环枚举定义的步骤:
enum Weekdays {
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
};
enum Weekdays {
Monday = 1,
Tuesday = 2,
Wednesday = 3,
Thursday = 4,
Friday = 5,
Saturday = 6,
Sunday = 7
};
Weekdays today = Tuesday;
这样,变量today的值就被设置为Tuesday。
推荐的腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云