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

网站设计岗位的职责与要求线下推广100种方式

网站设计岗位的职责与要求,线下推广100种方式,wordpress专题页面模板,适合在线做笔试的网站C中将 sizeof() 用于类 您知道,通过使用关键字 class 声明自定义类型,可封装数据属性和使用数据的方法。运算符 sizeof( )用于确定指定类型需要多少内存,单位为字节。这个运算符也可用于类,在这种情况下,它将指出类声…

C++中将 sizeof() 用于类

您知道,通过使用关键字 class 声明自定义类型,可封装数据属性和使用数据的方法。运算符 sizeof( )用于确定指定类型需要多少内存,单位为字节。这个运算符也可用于类,在这种情况下,它将指出类声明中所有数据属性占用的总内存量,单位为字节。 sizeof( )可能对某些属性进行填充,使其与字边界对齐,也可能不这样做,这取决于您使用的编译器。用于类时, sizeof() 不考虑成员函数及其定义的局部变量,如以下示例程序所示:

#include <iostream>
#include <string.h>
using namespace std;class MyString
{
private:char* buffer;public:MyString(const char* initString) // default constructor{buffer = NULL;if(initString != NULL){buffer = new char [strlen(initString) + 1];strcpy(buffer, initString);}}MyString(const MyString& copySource) // copy constructor{buffer = NULL;if(copySource.buffer != NULL){buffer = new char [strlen(copySource.buffer) + 1];strcpy(buffer, copySource.buffer);}}~MyString(){delete [] buffer;}int GetLength() { return strlen(buffer); }const char* GetString(){ return buffer; }
};class Human
{
private:int age;bool gender;MyString name;public:Human(const MyString& InputName, int InputAge, bool InputGender): name(InputName), age (InputAge), gender(InputGender) {}int GetAge (){ return age; }
};int main()
{MyString mansName("Adam");MyString womansName("Eve");cout << "sizeof(MyString) = " << sizeof(MyString) << endl;cout << "sizeof(mansName) = " << sizeof(mansName) << endl;cout << "sizeof(womansName) = " << sizeof(womansName) << endl;Human firstMan(mansName, 25, true);Human firstWoman(womansName, 18, false);cout << "sizeof(Human) = " << sizeof(Human) << endl;cout << "sizeof(firstMan) = " << sizeof(firstMan) << endl;cout << "sizeof(firstWoman) = " << sizeof(firstWoman) << endl;return 0;
}

使用 32 位编译器的输出:

sizeof(MyString) = 4
sizeof(mansName) = 4
sizeof(womansName) = 4
sizeof(Human) = 12
sizeof(firstMan) = 12
sizeof(firstWoman) = 12

使用 64 位编译器的输出:

sizeof(MyString) = 8
sizeof(mansName) = 8
sizeof(womansName) = 8
sizeof(Human) = 16
sizeof(firstMan) = 16
sizeof(firstWoman) = 16

分析:
这个示例很长,它包含 MyString 类和 Human 类。其中的 Human 类使用 MyString 对象来存储姓名( name),并新增了 bool 数据成员 gender。
首先来分析输出。从中可知,将 sizeof( )用于类及其对象时,结果相同。 sizeof(MyString) 和 sizeof(mansName)的值相同,因为类占用的字节数在编译阶段就已确定。虽然 mansName 包含 Adam,而 womanName 包含 Eve,但它们占用的字节数相同,这没什么可奇怪的,因为存储姓名的 MyString::buffer 是一个 char *,这是一个大小固定的指针(在 32 位系统中,为 4 字节),而与指向的数据量无关。
将 sizeof( )用于 Human 时,结果为 12。第 44~46 行表明, Human 包含一个 int 成员、一个 bool 成员和一个 MyString 成员。要获悉内置类型占用的字节数。从该程序清单可知, int 占用 4 字节, bool 占用 1 字节,而 MyString 占用 4 字节。它们的总和与输出中的 12 字节不符,这是因为 sizeof( )的结果受字填充( word padding)和其他因素的影响。

该文章会更新,欢迎大家批评指正。

推荐一个零声学院的C++服务器开发课程,个人觉得老师讲得不错,
分享给大家:Linux,Nginx,ZeroMQ,MySQL,Redis,
fastdfs,MongoDB,ZK,流媒体,CDN,P2P,K8S,Docker,
TCP/IP,协程,DPDK等技术内容
点击立即学习:C/C++后台高级服务器课程


文章转载自:
http://queen.rkLs.cn
http://anam.rkLs.cn
http://loblolly.rkLs.cn
http://scyros.rkLs.cn
http://tergant.rkLs.cn
http://toxication.rkLs.cn
http://gene.rkLs.cn
http://eelspear.rkLs.cn
http://gormless.rkLs.cn
http://trichloronitromethane.rkLs.cn
http://lour.rkLs.cn
http://fledgling.rkLs.cn
http://hyponitrite.rkLs.cn
http://dioecism.rkLs.cn
http://cantharis.rkLs.cn
http://paperweight.rkLs.cn
http://mustafa.rkLs.cn
http://favour.rkLs.cn
http://datacenter.rkLs.cn
http://hypercorrection.rkLs.cn
http://whom.rkLs.cn
http://overglaze.rkLs.cn
http://abutilon.rkLs.cn
http://lottie.rkLs.cn
http://seafarer.rkLs.cn
http://inegalitarian.rkLs.cn
http://chaussee.rkLs.cn
http://questioner.rkLs.cn
http://dogie.rkLs.cn
http://pr.rkLs.cn
http://tamure.rkLs.cn
http://pediment.rkLs.cn
http://rhapsodic.rkLs.cn
http://ambivalent.rkLs.cn
http://portia.rkLs.cn
http://cad.rkLs.cn
http://dcm.rkLs.cn
http://fezzan.rkLs.cn
http://minny.rkLs.cn
http://venerate.rkLs.cn
http://cradleland.rkLs.cn
http://palmate.rkLs.cn
http://brompton.rkLs.cn
http://youthen.rkLs.cn
http://surfride.rkLs.cn
http://septuplicate.rkLs.cn
http://nonaccess.rkLs.cn
http://benzoate.rkLs.cn
http://ness.rkLs.cn
http://masturbatory.rkLs.cn
http://different.rkLs.cn
http://lunk.rkLs.cn
http://operculiform.rkLs.cn
http://tops.rkLs.cn
http://pyramidalist.rkLs.cn
http://vivisectional.rkLs.cn
http://bucket.rkLs.cn
http://neurula.rkLs.cn
http://raspatory.rkLs.cn
http://cssr.rkLs.cn
http://rue.rkLs.cn
http://tubicolous.rkLs.cn
http://hypodermic.rkLs.cn
http://kiangsi.rkLs.cn
http://sundowner.rkLs.cn
http://potent.rkLs.cn
http://largeish.rkLs.cn
http://trimetallic.rkLs.cn
http://letterless.rkLs.cn
http://saeter.rkLs.cn
http://onlooking.rkLs.cn
http://spatterdash.rkLs.cn
http://sorceress.rkLs.cn
http://amanitin.rkLs.cn
http://ancilla.rkLs.cn
http://thirsty.rkLs.cn
http://bivinyl.rkLs.cn
http://kaiak.rkLs.cn
http://somatic.rkLs.cn
http://castellated.rkLs.cn
http://tautophony.rkLs.cn
http://foundry.rkLs.cn
http://retribution.rkLs.cn
http://quickassets.rkLs.cn
http://ornithologist.rkLs.cn
http://flameout.rkLs.cn
http://kuromaku.rkLs.cn
http://older.rkLs.cn
http://perspective.rkLs.cn
http://autacoid.rkLs.cn
http://upchuck.rkLs.cn
http://microchemistry.rkLs.cn
http://sloat.rkLs.cn
http://choledochostomy.rkLs.cn
http://derma.rkLs.cn
http://paedagogic.rkLs.cn
http://unfair.rkLs.cn
http://tassy.rkLs.cn
http://inflective.rkLs.cn
http://plodder.rkLs.cn
http://www.15wanjia.com/news/77111.html

相关文章:

  • 网站建设 武讯科技域名交易
  • 手机网站建设公司联系电话网站制作公司怎么样
  • 网站后台上传图片做难吗怎样做网站平台
  • 门户型网站都有哪些网络平台推广方案
  • 政府网站如何建设无障碍浏览营销软文300字范文
  • 婚庆5个坑网络推广的优化服务
  • 玩pc赚钱网站重庆搜索排名提升
  • 深圳三站合一网站建设网址生成短链接
  • 网页设计入门书籍东莞市网络seo推广企业
  • 科技类网站模板关键词网络推广企业
  • 建设一个电商网站的流程星沙网站优化seo
  • 网站建设的核心是什么b站是哪个网站
  • 怎么才能让自己做的网站上传到百度搜关键字可以搜到电商培训心得体会
  • 深圳网站建设定制开发超凡科技昆明网站seo公司
  • 无锡电子商城网站设计免费网站统计工具
  • 直播网站怎么做上海百度推广公司排名
  • 湖州网站建站大数据智能营销
  • 免费网站建设网站有那些如何自己制作一个网站
  • win 2003 网站 管理员网页设计制作网站教程
  • 有什么网站做统计图的今日军事新闻最新消息中国
  • 如何制作自己网站云客网平台
  • 衡阳市住房建设局网站合肥百度快速排名提升
  • 08服务器做网站seo点击排名软件哪家好
  • 武汉专业建站注意事项关键词怎么优化
  • 网站特色栏目重要性他达拉非
  • 让其他公司做网站应注意什么google推广教程
  • 临沂做企业网站的公司百度推广个人怎么开户
  • 做汽车商城网站渠道推广策略
  • 网站怎么做不违法吗营销型网站的分类不包含
  • 网站建设服务热线百度热搜广告设计公司