创建枚举数据类型,定义三个车辆名称(公共汽车,汽车,自行车),常数整数值分别为5,6和7 [英] To create an enumerated data type that defines three vehicle names (bus, car, bike) with constant integer values as 5, 6 and 7 respectively

查看:85
本文介绍了创建枚举数据类型,定义三个车辆名称(公共汽车,汽车,自行车),常数整数值分别为5,6和7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白如何解决这个问题。

请尽快给我回答



什么我试过了:



i我不清楚如何开始

i am not understanding how to do solve this question.
please give me answer as soon as posible

What I have tried:

i am not clear how to do start

推荐答案

尝试:

Try:
enum Vehicles
   {
   Bus = 5,
   Car = 6,
   Bike = 7
   };

快速谷歌enum可以让你在一小时前最好的部分: Enumerations(C ++) [ ^ ]或对课程材料的评论。

A quick google of "enum" would have got you this best part of an hour ago: Enumerations (C++)[^] or a review of your course materials.


enum vehicle
{
  bus = 5,
  car,
  bike,
};



由于 C ++ 11 ,您也可以使用作用域枚举并设置基础类型,请参阅枚举声明 - cppreference.com [ ^ ]。


Since C++11 you may also use scoped enumerations and set the underlying type as well, see enumeration declaration - cppreference.com[^].


这篇关于创建枚举数据类型,定义三个车辆名称(公共汽车,汽车,自行车),常数整数值分别为5,6和7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆