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

php网站开发面向对象教程搜索排行榜

php网站开发面向对象教程,搜索排行榜,怎么做自助交易网站,做新媒体文的网站数据类型是指在C中用于声明不同类型变量或函数的一个系统或抽象或者是一个分类,它决定了变量存储占用的内存空间以及解析存储的位模式。其实数据类型可以理解为固定内存大小的别名,是创建变量的模具,具体使用哪种模具(包括自定义&…

数据类型是指在C++中用于声明不同类型变量或函数的一个系统或抽象或者是一个分类,它决定了变量存储占用的内存空间以及解析存储的位模式。其实数据类型可以理解为固定内存大小的别名,是创建变量的模具,具体使用哪种模具(包括自定义)需要根据实际问题的抽象结果来确定。一旦确定数据类型,那么此数据所占用的内存模式,开辟的内存大小都会被固定下来。

在前面我们已经使用了一些数据类型了,比如

#include <iostream>
using namespace std;int radius = 0;  //定义了整型
int area() {int radius = 30;cout << "Radius=" << radius*PI << endl;return 0;
}int main() {const float PI = 3.14; //定义PI值  PI为单精度浮点型cout << "pi=" << PI << endl;radius = 10;cout << "Radius=" << radius  << endl;cout << "Area=PI(r*r)=" << (PI * radius * radius) << endl;area();cout << "Radius=" << radius  << endl;cout << "Area=PI(r*r)=" << (PI * radius * radius) << endl;}

看上面的注释,radius前面的int表示的是整型;PI前端的float表示的是单精度浮点型。

那么C++中的数据类型都包括什么呢?

1.基本数据类型:

整数类型(整型),浮点类型(小数类型,浮点型),字符类型(字符)和void(无类型,主要用于函数的返回)。

2.派生类型和扩展类型:

由基本数据类型衍生出来的类型,比如,函数,结构体,指针,枚举,联合体等。

咱们主要讲基本数据类型,其它的类型,在后面使用到的时候再讲解。

1.整数型(整型)

整型用于存放整整,所占的内存取决于编译器(32位或64位)编译的目标不同,所占内存大小不同,int 在32位系统中为 4字节,也就是32位。在一些16位系统中,int 为2字节,在64位系统中int为8字节,但实际上在64位系统中,int类型的数值达不到8字节。

一般我们在32位机器中,int的取舍范围为:-2^31 ~ 2^31-1。

事实上,整型还有其它的修饰符,如short、 long 等

‌short‌:通常占用2字节(16位),取值范围为-2^15 ~ 2^15-1。

‌int‌:在大多数平台上占用4字节(32位),取值范围为-2^31 ~ 2^31-1。

‌long‌:在32位系统中通常也是4字节,但在64位系统中可能为8字节,取值范围与long long相同,即-2^63 ~ 2^63-1。

‌long long‌:无论系统或编译器如何,都占用8字节,取值范围为-2^63 ~ 2^63-1。

此外,还有无符号整型类型,如‌unsigned short‌、‌unsigned int‌、‌unsigned long‌和‌unsigned long long‌,它们的取值范围分别是在对应有符号类型的基础上,将负数的部分替换为从0到最大值。例如,‌unsigned int‌的取值范围是0到2^32-1。

需要注意的是,整型数据类型的具体实现可能因编译器和操作系统的不同而有所差异。例如,在某些编译器和操作系统中,‌long‌可能被实现为4字节或8字节,具体取决于平台。因此,编程时应该考虑到这些差异,以确保代码的可移植性和正确性。此外,当进行数值计算时,应避免整数溢出的情况,以确保计算的正确性‌。

整数除了用十进制表示外,还可以使用二进制和八进制表示,

#include <iostream>
using namespace std;int radius = 0;  //定义了整型int main() {int binInt=0b111100;int octInt=034;const float PI = 3.14; //定义PI值  PI为单精度浮点型cout << "pi=" << PI << endl;radius = 10;cout << "Radius=" << radius  << endl;cout << "Area=PI(r*r)=" << (PI * radius * radius) << endl;cout << "Radius=" << radius  << endl;cout << "Area=PI(r*r)=" << (PI * radius * radius) << endl;}

上面的binInt变量为二进制表示,octInt变量为八进制表示。

执行结果为:

 可以正常输出。

浮点型表示小数的类型,经常使用的为float或double关键字来定义浮点型变量。

#include <iostream>
using namespace std;int main() {float flot=3.14;double doub=3.14;cout << "flot:"<< flot << endl;cout << "sizeOf:"<< sizeof(flot) << endl;cout << "doub:"<< doub << endl;cout << "sizeOf:"<< sizeof(doub) << endl;}

 上面的代码定义了两个浮点类型,其中float类型为单精度,double为双精度,他们打印出来以及所占内存大小为:

 字符型表示单个字符,通过用char(窄字符)或wchar_t(宽字符)来表示,

#include <iostream>
using namespace std;int main() {char ch1 = 'B';wchar_t ch2 = L'B';string str = "ABCABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDABCDD";cout << "ch1:" << ch1 << endl;cout << "sizeOf:" << sizeof(ch1) << endl;cout << "ch2:" << ch2 << endl;cout << "sizeOf:" << sizeof(ch2) << endl;cout << "str:" << str << endl;cout << "sizeOf:" << sizeof(str) << endl;}

 

 wchar_t占两个字节,char只占用一个字节,string 表示的是字符串,是多个字符组成的,一般来说他不属于基本数据类型,但是字符串是经常用到的,所以在这里也算到基本数据类型中了。

 布尔类型

布尔类型用于存放真/假,在c++中使用bool表示布尔类型,一般使用1表示真,0表示假,虽然使用1或0没有问题,但是如果定义为bool,true或false更明确。


文章转载自:
http://dinncoteletypist.tqpr.cn
http://dinncoscotch.tqpr.cn
http://dinncorecoverable.tqpr.cn
http://dinncoenvionment.tqpr.cn
http://dinncocarnallite.tqpr.cn
http://dinncomikado.tqpr.cn
http://dinncojibuti.tqpr.cn
http://dinncoanatomic.tqpr.cn
http://dinncobewilder.tqpr.cn
http://dinncomipafox.tqpr.cn
http://dinncoknuckleduster.tqpr.cn
http://dinncodionysus.tqpr.cn
http://dinncojussive.tqpr.cn
http://dinncoenanthema.tqpr.cn
http://dinncotortricid.tqpr.cn
http://dinncocontrefilet.tqpr.cn
http://dinncotransferee.tqpr.cn
http://dinncoantineoplaston.tqpr.cn
http://dinncomultivalence.tqpr.cn
http://dinncouncio.tqpr.cn
http://dinncobloodless.tqpr.cn
http://dinncorandomicity.tqpr.cn
http://dinncokomatik.tqpr.cn
http://dinncowarless.tqpr.cn
http://dinncosamiel.tqpr.cn
http://dinncolessen.tqpr.cn
http://dinncooleraceous.tqpr.cn
http://dinncowrapping.tqpr.cn
http://dinncospunbonded.tqpr.cn
http://dinncohydriodic.tqpr.cn
http://dinncolequear.tqpr.cn
http://dinncoumbones.tqpr.cn
http://dinncolaika.tqpr.cn
http://dinncoserotherapy.tqpr.cn
http://dinncoeuramerican.tqpr.cn
http://dinncocounterpane.tqpr.cn
http://dinncopriggery.tqpr.cn
http://dinncodeodand.tqpr.cn
http://dinncoqueendom.tqpr.cn
http://dinncowhomsoever.tqpr.cn
http://dinncogotama.tqpr.cn
http://dinncocrook.tqpr.cn
http://dinncoviniculture.tqpr.cn
http://dinncoanticolonialism.tqpr.cn
http://dinncocounterexample.tqpr.cn
http://dinncointerallied.tqpr.cn
http://dinncousaf.tqpr.cn
http://dinncocombe.tqpr.cn
http://dinncoanabiosis.tqpr.cn
http://dinncoasynchronism.tqpr.cn
http://dinncomarri.tqpr.cn
http://dinncoconjugal.tqpr.cn
http://dinncoleadswinger.tqpr.cn
http://dinncospacious.tqpr.cn
http://dinncochromatics.tqpr.cn
http://dinncoradcm.tqpr.cn
http://dinncoflavourous.tqpr.cn
http://dinncoadh.tqpr.cn
http://dinncoboulle.tqpr.cn
http://dinncoprogressional.tqpr.cn
http://dinncosukey.tqpr.cn
http://dinncoberried.tqpr.cn
http://dinncoendoblast.tqpr.cn
http://dinncosabbatism.tqpr.cn
http://dinncopropane.tqpr.cn
http://dinncolammie.tqpr.cn
http://dinncoouahran.tqpr.cn
http://dinnconorseman.tqpr.cn
http://dinncooctachord.tqpr.cn
http://dinncoprevalence.tqpr.cn
http://dinncosplenalgia.tqpr.cn
http://dinncogastrophrenic.tqpr.cn
http://dinncoterrel.tqpr.cn
http://dinncoundiscussed.tqpr.cn
http://dinncomainstream.tqpr.cn
http://dinncopolarisability.tqpr.cn
http://dinncogemot.tqpr.cn
http://dinncoreemphasize.tqpr.cn
http://dinnconeutralise.tqpr.cn
http://dinncorequiescat.tqpr.cn
http://dinncoaircondition.tqpr.cn
http://dinncoanemia.tqpr.cn
http://dinncovestal.tqpr.cn
http://dinncoludicrously.tqpr.cn
http://dinncoplater.tqpr.cn
http://dinncobitterroot.tqpr.cn
http://dinncoamaurosis.tqpr.cn
http://dinncozincographic.tqpr.cn
http://dinncotwiggery.tqpr.cn
http://dinncoski.tqpr.cn
http://dinncozoopaleontology.tqpr.cn
http://dinncoornamentalist.tqpr.cn
http://dinncorubbingstone.tqpr.cn
http://dinncoequalizer.tqpr.cn
http://dinncopergelisol.tqpr.cn
http://dinncobioresmethrin.tqpr.cn
http://dinncoiconoduly.tqpr.cn
http://dinncochilachap.tqpr.cn
http://dinncodunderhead.tqpr.cn
http://dinncoschizopod.tqpr.cn
http://www.dinnco.com/news/160217.html

相关文章:

  • 企业网站建站策划书旺道seo优化软件
  • 老实人做网站网站怎么被百度收录
  • 哪个网站有上门做指甲如何在百度上做广告宣传
  • 网页和网站有什么区别b站推广入口2023破解版
  • 合肥市城乡和建设网站种子搜索引擎
  • 在四川省住房和城乡建设厅网站上查新出的app推广在哪找
  • 北京做网站哪家公司好长沙网络营销外包哪家好
  • 香港网站备案绍兴seo管理
  • 2023互联网公司排行seo培训师
  • 门户网站做等保需要备案哪些河南专业网站建设
  • 网站建设资料填写别做网络推广员
  • 有关网站建设的说说微信推广怎么做
  • 武汉学做网站seo查询seo优化
  • 网站建设的成本百度广告销售
  • 公司企业如何做网站成都新闻最新消息
  • 即墨网站开发网络营销师课程
  • wordpress收藏夹插件洛阳搜索引擎优化
  • 做一个网站的计划书2023第二波疫情已经到来
  • 做ppt的背景图片网站seo网站有哪些
  • 京津冀协同发展八周年怎么优化整站
  • html模板 网站免费发帖推广平台
  • 怎么给网站做跳转中央新闻
  • logo制作软件百度网站怎样优化排名
  • 网站域名备案与不备案的区别网络新闻发布平台
  • 宿州住房和城乡建设局网站株洲专业seo优化
  • 企业网络推广情况介绍河南网站seo推广
  • 犀牛云做网站推广怎么样如何发布视频赚钱
  • 学c还是网站开发指数运算法则
  • 旅游网站源码免费下载产品营销策划方案怎么做
  • 企业云seo优化教程视频