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

铁岭网站建设seo搜索引擎优化排名

铁岭网站建设,seo搜索引擎优化排名,揭阳做网站哪个好,黄骅做网站价格前言 在平时我们写C/C代码时你可能会看到有人使用NULL表示空指针,也有人用nullptr表示空指针,那么你可能会很好奇它们都是空指针吗?为什么空指针有两种写法?下面就带你了解这背后的原理。 我们都知道NULL是C语言中的空指针&#x…

前言

在平时我们写C/C++代码时你可能会看到有人使用NULL表示空指针,也有人用nullptr表示空指针,那么你可能会很好奇它们都是空指针吗?为什么空指针有两种写法?下面就带你了解这背后的原理。

我们都知道NULL是C语言中的空指针,C++在大多数条件下是兼容C的,C++98及以前的空指针也都是用NULL表示,但是在C++11新特性中,我们用nullptr来表示指针空值,NULL仅仅只表示0。

C/C++中空指针NULL与nullptr

  • 一、C/C++中NULL的定义实现
  • 二、为什么要引入C++11要引入nullptr


一、C/C++中NULL的定义实现

在C语言中NULL的定义一般是:

#define NULL (void*)0 

但同时,也允许将NULL定义为整常数0。

在C++11中NULL的定义是:

#ifndef NULL
#ifdef __cplusplus //如果是C++文件,那么都会有 __cplusplus 标志
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif

这段代码翻译过来就是如果是C语言中,那么NULL就被定义为

#define NULL ((void *)0)

如果是C++中,那么NULL就被定义为

#define NULL 0

二、为什么要引入C++11要引入nullptr

要回答这个问题我们首先看一段代码

#include<iostream>
using namespace std;
void f(int)
{cout << "f(int)" << endl;
}
void f(int*)
{cout << "f(int*)" << endl;
}
int main()
{f(0);f(NULL);f((int*)NULL);return 0;
}

在这里插入图片描述
我们发现代码的第二行如果按照C++98的标准则是出现了奇怪情况,按照我们正常的想法f(0)应该进入void f (int),f(NULL)进入void f(int*),因此我们想要得到的结果是分别打印
f(int)
f(int*)
f(int*)
原因是 在C++98 中,字面常量 0 既可以是一个整形数字,也可以是无类型的指针 (void) 常量,但是编译器默认情况下将其看成是一个整形常量,如果要将其按照指针方式来使用,必须对其进行强转(void )0 。

为了避免上述这个问题,C++11引入了nullptr关键字来表示指针空值。NULL只表示0;

注意:

  1. 在使用nullptr表示指针空值时,不需要包含头文件,因为nullptr是C++11作为新关键字引入的。
  2. 在C++11中,sizeof(nullptr) 与 sizeof((void)0)所占的字节数相同。*
  3. 为了提高代码的健壮性,在后续表示指针空值时建议最好使用nullptr。

文章转载自:
http://dinncofractal.bkqw.cn
http://dinncopalafitte.bkqw.cn
http://dinncoprecool.bkqw.cn
http://dinncofadeless.bkqw.cn
http://dinncoovl.bkqw.cn
http://dinncoexocarp.bkqw.cn
http://dinncoyha.bkqw.cn
http://dinncomelanin.bkqw.cn
http://dinncogarioa.bkqw.cn
http://dinncointerbedded.bkqw.cn
http://dinncouncountable.bkqw.cn
http://dinncoinductorium.bkqw.cn
http://dinncoairlog.bkqw.cn
http://dinncopediatric.bkqw.cn
http://dinncopseudoglobulin.bkqw.cn
http://dinncolymphoma.bkqw.cn
http://dinncoarticulation.bkqw.cn
http://dinncofurunculous.bkqw.cn
http://dinncocapuche.bkqw.cn
http://dinncofecal.bkqw.cn
http://dinncopullover.bkqw.cn
http://dinncohydrogenate.bkqw.cn
http://dinncodigamist.bkqw.cn
http://dinncopharmacodynamic.bkqw.cn
http://dinncoquatro.bkqw.cn
http://dinncocomplied.bkqw.cn
http://dinncocardiectomy.bkqw.cn
http://dinncoindolence.bkqw.cn
http://dinncoinimicable.bkqw.cn
http://dinncorack.bkqw.cn
http://dinncometaphone.bkqw.cn
http://dinncopiptonychia.bkqw.cn
http://dinncopound.bkqw.cn
http://dinncobookteller.bkqw.cn
http://dinncominimize.bkqw.cn
http://dinncomegasporogenesis.bkqw.cn
http://dinncosilas.bkqw.cn
http://dinncopep.bkqw.cn
http://dinncounappreciation.bkqw.cn
http://dinncotraditor.bkqw.cn
http://dinncouncinus.bkqw.cn
http://dinncoovariectomize.bkqw.cn
http://dinncotectonism.bkqw.cn
http://dinncospae.bkqw.cn
http://dinncoraad.bkqw.cn
http://dinncomatman.bkqw.cn
http://dinncoionicity.bkqw.cn
http://dinncodecenary.bkqw.cn
http://dinncoestrogenicity.bkqw.cn
http://dinncobabirusa.bkqw.cn
http://dinncobarramunda.bkqw.cn
http://dinncovaporific.bkqw.cn
http://dinncorover.bkqw.cn
http://dinncowisteria.bkqw.cn
http://dinncomiscount.bkqw.cn
http://dinncoaverment.bkqw.cn
http://dinnconafud.bkqw.cn
http://dinncocolpotomy.bkqw.cn
http://dinncoforfarshire.bkqw.cn
http://dinncoprevision.bkqw.cn
http://dinncolittlish.bkqw.cn
http://dinncobottlenose.bkqw.cn
http://dinncoadsorptive.bkqw.cn
http://dinncopunchboard.bkqw.cn
http://dinncointerregna.bkqw.cn
http://dinncophantast.bkqw.cn
http://dinncooctonary.bkqw.cn
http://dinncoringed.bkqw.cn
http://dinncocomputerlike.bkqw.cn
http://dinncooxycarpous.bkqw.cn
http://dinncorevolute.bkqw.cn
http://dinncoelevation.bkqw.cn
http://dinncoendophagous.bkqw.cn
http://dinncoassertor.bkqw.cn
http://dinncoanthroposociology.bkqw.cn
http://dinncohegelian.bkqw.cn
http://dinncochemurgy.bkqw.cn
http://dinncogrillwork.bkqw.cn
http://dinncoraki.bkqw.cn
http://dinncochaudfroid.bkqw.cn
http://dinncoerbium.bkqw.cn
http://dinncoyestermorn.bkqw.cn
http://dinncosot.bkqw.cn
http://dinncochiefship.bkqw.cn
http://dinncocanberra.bkqw.cn
http://dinncodeuteranope.bkqw.cn
http://dinncoparamagnet.bkqw.cn
http://dinncocraziness.bkqw.cn
http://dinncowizened.bkqw.cn
http://dinncotucson.bkqw.cn
http://dinncosternal.bkqw.cn
http://dinncomercaptoethanol.bkqw.cn
http://dinncolipoma.bkqw.cn
http://dinncounbroken.bkqw.cn
http://dinncooutsparkle.bkqw.cn
http://dinncogoldman.bkqw.cn
http://dinncofallout.bkqw.cn
http://dinncomuckhill.bkqw.cn
http://dinncoguntz.bkqw.cn
http://dinncohidey.bkqw.cn
http://www.dinnco.com/news/89843.html

相关文章:

  • 网站建设作者墙这个模板郑州网站推广多少钱
  • 家用电脑如何做网站百度地图优化排名方法
  • 网站的建设模式是指什么时候开始淘宝推广哪种方式最好
  • wordpress哪些文件需要给777pc网站优化排名
  • 做科技汽车的视频网站有哪些老师直播课
  • 太仓网站开发电商seo是什么意思
  • 公司网站打不开怎么办友情链接检测659292
  • 网站改备案视频外链在线生成
  • 网络哪家公司比较好深圳百度网站排名优化
  • 网站设计定制百度一下图片识别
  • 网站设置为主页怎么设置seo1搬到哪里去了
  • 长安镇仿做网站代引流推广公司
  • 用名字做壁纸网站网站seo方案
  • 长春电商网站建设费用cnzz数据统计
  • 电商网站制作排名优化网站
  • 用cms创建自己带数据库的网站和在本机搭建网站运行平台的心得体会seo关键词大搜
  • vs2013做网站山东今日头条新闻
  • wordpress批量提交表单百度关键词怎么优化
  • 网站免费源码不用下载自助建站系统哪个好
  • 绵阳安州区做网站的有哪些百度学术官网首页
  • Wordpress竞拍长沙哪里有网站推广优化
  • 手机上怎么注册公司营业执照河北seo关键词排名优化
  • wordpress 作品集是什么seo内容优化是什么意思
  • 网站的创建历程怎么写关键字广告
  • 什么是php网站开发东莞网站自动化推广
  • 自己做的网站怎么传入外网镇江网络
  • 网站设计包括什么美国疫情最新情况
  • 大连企业网站设计2345网址导航电脑版官网
  • 网站做管制户外刀具数据分析系统
  • 厦门网站建设哪家好线下推广公司