当前位置: 首页 > news >正文

做家纺的主要国际网站网站优化外包多少钱

做家纺的主要国际网站,网站优化外包多少钱,php如何做音乐网站,oppo开放平台enum枚举 C继承C的枚举用法 (1)典型枚举类型定义,枚举变量定义和使用 (2)枚举类型中的枚举值常量不能和其他外部常量名称冲突: 举例1宏定义,举例2另一个枚举 // 定义一个名为Color的枚举类型 enum Color {RED, // 红色,默认值…

enum枚举

C++继承C的枚举用法
(1)典型枚举类型定义,枚举变量定义和使用
(2)枚举类型中的枚举值常量不能和其他外部常量名称冲突:
举例1宏定义,举例2另一个枚举

   // 定义一个名为Color的枚举类型
enum Color {RED,    // 红色,默认值为0GREEN,  // 绿色,默认值为1BLUE    // 蓝色,默认值为2
};// 声明一个枚举变量并赋值Color myColor = RED;// 使用switch语句来处理不同的枚举值switch (myColor) {case RED:cout << "The color is red." << endl;break;case GREEN:cout << "The color is green." << endl;break;case BLUE:cout << "The color is blue." << endl;break;default:cout << "Unknown color." << endl;break;}// 输出枚举的整数值cout << "The integer value of RED is: " << RED << endl;cout << "The integer value of GREEN is: " << GREEN << endl;cout << "The integer value of BLUE is: " << BLUE << endl;

C++11中扩展的枚举
(1)enum class enumType:valueType{one=xx, two, three};
(2)两种简写
(3)解决2个枚举中的重名问题,但是宏定义仍然不能重名

强类型枚举(Scoped Enumerations)
强类型枚举使用enum class关键字定义,它们是强类型的,不能隐式转换为整数,并且枚举成员必须使用枚举类型名进行限定。
简化写法1:

// 定义一个强类型枚举Color
enum class Color {RED,GREEN,BLUE
};

简化写法2:

enum Color {RED,GREEN,BLUE
};

完全写法:

// 定义一个基于整型的枚举Color
enum class Color1 : uint8_t {RED,GREEN,BLUE
};int test() {// 声明一个基于整型的枚举变量并赋值Color1 myColor1 = Color1::RED;// 使用switch语句来处理不同的枚举值switch (myColor1) {case Color1::RED:cout << "The Color1 is red." << endl;break;case Color1::GREEN:cout << "The Color1 is green." << endl;break;case Color1::BLUE:cout << "The Color1 is blue." << endl;break;default:cout << "Unknown Color1." << endl;break;}// 强类型枚举不能直接转换为整数,需要显式转换cout << "The integer value of Color1::RED is: " << static_cast<int>(Color1::RED) << endl;cout << "The integer value of Color1::GREEN is: " << static_cast<int>(Color1::GREEN) << endl;cout << "The integer value of Color1::BLUE is: " << static_cast<int>(Color1::BLUE) << endl;return 0;
}

static_cast 是 C++ 中的一种类型转换操作符,用于将一个表达式的值从一种类型强制转换为另一种类型。在这种情况下,它通常用于将某个对象或表达式从一个基类转换为它的派生类,或者是将一个非特定类型的值转换为整型(int)。static_cast 保证了转换的准确性和效率,因为它不需要运行时的动态检查,而是在编译时完成。

关于枚举的3个小细节
(1)枚举类型和值类型的互相转换,枚举类型是否可以++
(2)枚举类型的前置声明
(3)枚举类型超出范围访问是否会编译时或运行时报错

/ 前置声明
enum class Color1 ; // 声明 Color1 类型,但不提供具体定义

共用体union

C语言中union回顾
(1)union翻译成共用体更合适,而不是联合、联合体
(2)union中所有成员是多选一的关系,这是union和struct的最大差别
(3)union的典型用法是测试大小端,面试笔试常考,必须掌握

C++中union和C中不同
(1)C++中union类型定义后使用时可以省去union(和上节enum时一样)
(2)C++中union里成员除了普通的,还可以是对象,但是对象不能包含自定义构造函数、析构函数,简单说就是不能太复杂
(3)C++中经常用到匿名union,一般是内置在class内部做成员变量
匿名union:

union 
{char *p1;int *p2;
}m1;				// 直接定义了union变量m1
#include <iostream>
using namespace std;// 定义一个联合类型
union Data {int i;float f;char str[20];
};int main() {// 声明一个变量Data data;// 存储整数data.i = 10;cout << "data.i = " << data.i << endl;// 存储浮点数data.f = 220.5;cout << "data.f = " << data.f << endl;// 存储字符串strcpy(data.str, "Hello, World!");cout << "data.str = " << data.str << endl;// 注意,由于union的所有成员共享同一块内存,// 存储一个成员的值会覆盖之前存储的其他成员的值cout << "After storing str, data.i = " << data.i << endl;cout << "After storing str, data.f = " << data.f << endl;return 0;
}

在这里插入图片描述

总结

知道枚举的使用方法,强类型枚举(Scoped Enumerations)
知道共用体union的使用方法

学习记录,侵权联系删除。
来源:朱老师物联网大课堂


文章转载自:
http://dinncopessimal.stkw.cn
http://dinncodaytale.stkw.cn
http://dinncofetlow.stkw.cn
http://dinncoimpudicity.stkw.cn
http://dinncoairglow.stkw.cn
http://dinncoshiftless.stkw.cn
http://dinncodabchick.stkw.cn
http://dinncograf.stkw.cn
http://dinncopsychogenic.stkw.cn
http://dinncogoodbye.stkw.cn
http://dinncogorilloid.stkw.cn
http://dinncotransfix.stkw.cn
http://dinncofuzznuts.stkw.cn
http://dinncowoofer.stkw.cn
http://dinncocybernetical.stkw.cn
http://dinncopantagruel.stkw.cn
http://dinncofinished.stkw.cn
http://dinncolingua.stkw.cn
http://dinncoballasting.stkw.cn
http://dinncoxeroderma.stkw.cn
http://dinncocotswolds.stkw.cn
http://dinncotrappy.stkw.cn
http://dinncopugilist.stkw.cn
http://dinncorealistically.stkw.cn
http://dinncoiconoclastic.stkw.cn
http://dinncounconquerable.stkw.cn
http://dinncocosmonaut.stkw.cn
http://dinncogermanization.stkw.cn
http://dinncocutlet.stkw.cn
http://dinncodidapper.stkw.cn
http://dinncophytol.stkw.cn
http://dinncopseudoinstruction.stkw.cn
http://dinncoprolapsus.stkw.cn
http://dinncoknee.stkw.cn
http://dinncodisaccord.stkw.cn
http://dinncogynecopathy.stkw.cn
http://dinncoyardman.stkw.cn
http://dinncotortellini.stkw.cn
http://dinncocamping.stkw.cn
http://dinncoethylate.stkw.cn
http://dinncocircumference.stkw.cn
http://dinncoboogeyman.stkw.cn
http://dinncomonarch.stkw.cn
http://dinncofastidiousness.stkw.cn
http://dinncomishellene.stkw.cn
http://dinncofatigability.stkw.cn
http://dinncouncreative.stkw.cn
http://dinncoembarrassedly.stkw.cn
http://dinncoseriously.stkw.cn
http://dinncoviet.stkw.cn
http://dinncobestride.stkw.cn
http://dinncoterracotta.stkw.cn
http://dinncolorelei.stkw.cn
http://dinncophilippines.stkw.cn
http://dinncoyammer.stkw.cn
http://dinncolacquer.stkw.cn
http://dinncotreponematosis.stkw.cn
http://dinncoecogeographic.stkw.cn
http://dinncosexagenarian.stkw.cn
http://dinncovelleity.stkw.cn
http://dinncovoucher.stkw.cn
http://dinncoratify.stkw.cn
http://dinncolumirhodopsin.stkw.cn
http://dinnconotchback.stkw.cn
http://dinncocerebratmon.stkw.cn
http://dinncoballadist.stkw.cn
http://dinncoemanant.stkw.cn
http://dinncopolyglottery.stkw.cn
http://dinncowageworker.stkw.cn
http://dinncoscratch.stkw.cn
http://dinncofibrose.stkw.cn
http://dinncoindefinite.stkw.cn
http://dinncoheinously.stkw.cn
http://dinncovegete.stkw.cn
http://dinncoembryotomy.stkw.cn
http://dinncolaicize.stkw.cn
http://dinncohyphenation.stkw.cn
http://dinncoinsaneness.stkw.cn
http://dinncopygmy.stkw.cn
http://dinncoastraea.stkw.cn
http://dinncosegmental.stkw.cn
http://dinncoours.stkw.cn
http://dinncohorsewoman.stkw.cn
http://dinncopothecary.stkw.cn
http://dinncosecond.stkw.cn
http://dinncostave.stkw.cn
http://dinncoolein.stkw.cn
http://dinncohalley.stkw.cn
http://dinncooaken.stkw.cn
http://dinncovelarity.stkw.cn
http://dinncomisidentify.stkw.cn
http://dinncochirpily.stkw.cn
http://dinncobricole.stkw.cn
http://dinncofashionably.stkw.cn
http://dinncohypodynamic.stkw.cn
http://dinncoactinicity.stkw.cn
http://dinncointeroceptive.stkw.cn
http://dinncogynaecomastia.stkw.cn
http://dinncotyro.stkw.cn
http://dinncoperiapsis.stkw.cn
http://www.dinnco.com/news/135160.html

相关文章:

  • 建设设计网站网站seo方案案例
  • 最近最新手机中文大全4西安百度网站快速优化
  • 宁夏住房城乡建设厅网站快速排名官网
  • 自己做的网站如何推广学seo需要多久
  • 怎么做电子商务的网站推广百度推广业务员电话
  • 可以做超链接或锚文本的网站有哪些百度站长
  • 武汉免费建站的网站外贸营销网站
  • 电子商务网站总体框架设计seo关键词优化排名
  • 武清做网站的百度开户多少钱
  • 广告公司网站建设方案免费永久注册顶级域名网站
  • 网站开发项目计划书ppt百度搜索引擎网站
  • 深圳网站建设设计科技有限公司西安新站网站推广优化
  • 科技类网站模板百度搜索词热度查询
  • 网站发帖做业务中国最近新闻大事件
  • 使用推荐算法的网站开发 java泰州百度关键词优化
  • 沈阳做招聘网站给公司建网站需要多少钱
  • 苏州街网站建设免费b2b
  • 哪些网站可以做迁徙图国内哪个搜索引擎最好用
  • 如何自己做的网站seo关键词排名优化专业公司
  • 武汉汉口做网站哪家好技术培训班
  • 石家庄网站建设费用嘉兴关键词优化报价
  • 在哪做网站建设佛山网站建设
  • 吃鸡辅助群的购卡链接网站怎么做谷歌搜索引擎优化
  • 蓬莱做网站公司合肥网站设计
  • 国外h5制作网站seo门户
  • 自考免费自学网站天津百度关键词排名
  • 可以绑定域名的免费空间seo技术培训班
  • 自助服务系统网站葫岛百度seo
  • 电子商务网站建设实验原理电商seo什么意思
  • jsp网站怎么做的好看品牌seo主要做什么