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

建设网站平台网页制作软件哪个好

建设网站平台,网页制作软件哪个好,游戏公司做网站设计赚钱吗,公司门户app面试题目:1、题 int i10; const int*p &i; int *const* p &i; const在不同位置有什么不 同 2、const 修饰类成员变量是有什么特殊要求 3、const 修饰类成员函数会发什么 4、const 对象有什么意义 目录 前言 一、const的意义 二、const使用规则 1.初始化…

面试题目:1、题 int i=10;  const int*p = &i;  int *const* p = &i; const在不同位置有什么不

                        同

                  2、const 修饰类成员变量是有什么特殊要求

                  3、const 修饰类成员函数会发什么

                  4、const 对象有什么意义

                        

目录

前言

一、const的意义

二、const使用规则

1.初始化

2.const 修饰指针

1)const靠近谁,谁就是常量

2)或者 左边的是底层const,靠近右边的是顶层const

三、const使用限制

四、const类相关

1、定义数据成员

2、定义常量函数

3、定义const 对象



前言

对于任何语言设定限定符为了是程序设计者不破坏其语言设定的基础规则,使程序能够安全运行和稳定运行。本文对C++ 中const限定符做详细的解析。

一、const的意义

有时候我们希望我们定义的变量,希望它的值不能被修改,只能被使用;另一方面也随时保证警惕防止程序或其他设计者一不小心改变这个值,为了满足这一要求就通过const关键字加以限定 

二、const使用规则

1.初始化

const 修饰的变量在初始化就需要赋初值

const int i = 10;

const char* p = " big bird";

const 初始化时允许任意表达式作为初始值

const int r1 = 40;

const int r2 = r1*50;  

const引用的时候允许类型转换

const double  i = 3.14;

const int &r1 = i; 

其实实际程序做了隐形操作,建立了一个临时变量,真正的执行过程如下:

const double  i = 3.14;

const int &r1 = i;        //隐形操作

const int temp = i;     //隐形操作

const int &r1 = temp;

2.const 修饰指针

指针是对象而不是引用,因此它能像其他对象类型一样,允许把指针本身定义为常量。常量指针必须被初始化

int errorNum = 0;

int *const  currErr = &errorNum;        //就是currErr不能指向其他地址,顶层const

const int *p = &errorNum;                  //currErr可以指向其他地址,底层const,可以改变

                                                           //currErr所指向的内容

const double pi = 3.1415926;

const double *const pip = π           //双保险,地址指向和内容都不能修改

 const 修饰指针时 如果本身是常量,这是顶层const,如果指针可以改变就是底层const

如果以上不好理解,那么可以通过取巧的记忆方法:

1)const靠近谁,谁就是常量

const靠近类型,值就不改变,是底层const,const靠近 * 表明指针不能改变,底层const,如下:

const int *p = &errorNum; 

int *const  currErr = &errorNum;  

2)或者 左边的是底层const,靠近右边的是顶层const

三、const使用限制

        int i=0;

        int *const p = &i;

        int* p1 = p;                        //错误,p是常量类型,无法赋值

        const int a = 10;        

        int &r = a;                        //错误,a是常量,不能被引用成普通变量

四、const类相关

1、定义数据成员

class A
{private const int i;public A(int a);
}class A:A(int a):i(a)
{
}

类的数据成员为常量,那么就要在构造函数中初始化列表中初始化它,不能在构造函数中初始化 

2、定义常量函数

class A
{private string name;public A(string name);public string getName()const;public const string& getNameEx();
}A:A(string n):name(n)
{
}//表明该函数中不能修改成员变量
string A:getName()const
{return name;
}//表明返回值是常量
const string& A::getNameEx()
{return name;
}

如果const修饰返回值,那么返回值是常量,如果修饰的在函数声明后面,那么说明在该函数中不能修改成员变脸的值

3、定义const 对象

在 C++ 中,const 也可以用来修饰对象,称为 常对象 。 一旦将对象定义为常对象之后,就只能调用类的 const 成员(包括 const 成员变量和 const 成员函数)了。

const A* pA = new A("xiaoming");

pA->getName();                //正确,getName是常量成员函数

pA->getNameEx();            //错误,getNameEx不是常量成员函数


文章转载自:
http://dinncodropping.ssfq.cn
http://dinncotantalum.ssfq.cn
http://dinncovaluator.ssfq.cn
http://dinncoabsorptance.ssfq.cn
http://dinncojayhawk.ssfq.cn
http://dinncoyacket.ssfq.cn
http://dinncomonatomic.ssfq.cn
http://dinncocfc.ssfq.cn
http://dinncopav.ssfq.cn
http://dinncothermotics.ssfq.cn
http://dinncolaccolite.ssfq.cn
http://dinncoradioimmunological.ssfq.cn
http://dinncowoodcut.ssfq.cn
http://dinncoalecost.ssfq.cn
http://dinncophotolith.ssfq.cn
http://dinncoechinoid.ssfq.cn
http://dinncofso.ssfq.cn
http://dinncobleachers.ssfq.cn
http://dinncoillyria.ssfq.cn
http://dinncoduro.ssfq.cn
http://dinncoadulate.ssfq.cn
http://dinncohaul.ssfq.cn
http://dinncounfeeling.ssfq.cn
http://dinncoextra.ssfq.cn
http://dinncoebullient.ssfq.cn
http://dinncoendotracheal.ssfq.cn
http://dinncoelbe.ssfq.cn
http://dinncopompous.ssfq.cn
http://dinnconephron.ssfq.cn
http://dinncohereby.ssfq.cn
http://dinncofilmstrip.ssfq.cn
http://dinncopanicky.ssfq.cn
http://dinncodataller.ssfq.cn
http://dinncolao.ssfq.cn
http://dinncoexemplariness.ssfq.cn
http://dinncooctober.ssfq.cn
http://dinncogauger.ssfq.cn
http://dinncoanqing.ssfq.cn
http://dinncoherdbook.ssfq.cn
http://dinncostatism.ssfq.cn
http://dinncoet.ssfq.cn
http://dinncoimpromptu.ssfq.cn
http://dinncochilding.ssfq.cn
http://dinncoanthropogeny.ssfq.cn
http://dinncomerioneth.ssfq.cn
http://dinncoimpermeable.ssfq.cn
http://dinncowhoosis.ssfq.cn
http://dinncothanatophilia.ssfq.cn
http://dinncokentucky.ssfq.cn
http://dinncodetent.ssfq.cn
http://dinncodipteron.ssfq.cn
http://dinncoaffronted.ssfq.cn
http://dinnconaira.ssfq.cn
http://dinncohierurgy.ssfq.cn
http://dinnconorthallerton.ssfq.cn
http://dinncoaurar.ssfq.cn
http://dinncodivinization.ssfq.cn
http://dinncoantiapartheid.ssfq.cn
http://dinncosubtersurface.ssfq.cn
http://dinncoteknonymy.ssfq.cn
http://dinncooverlying.ssfq.cn
http://dinncoscripturally.ssfq.cn
http://dinncopolemological.ssfq.cn
http://dinncoemprise.ssfq.cn
http://dinncosedum.ssfq.cn
http://dinncothermocautery.ssfq.cn
http://dinncoamazedly.ssfq.cn
http://dinncoyester.ssfq.cn
http://dinncopolyhidrosis.ssfq.cn
http://dinncotenantlike.ssfq.cn
http://dinncoblanky.ssfq.cn
http://dinncoblew.ssfq.cn
http://dinncomoderately.ssfq.cn
http://dinncobarnsley.ssfq.cn
http://dinncoterrorist.ssfq.cn
http://dinncoswitchyard.ssfq.cn
http://dinncokeratoderma.ssfq.cn
http://dinncooximeter.ssfq.cn
http://dinncocorfam.ssfq.cn
http://dinncojointing.ssfq.cn
http://dinncorejon.ssfq.cn
http://dinncoskullguard.ssfq.cn
http://dinncohydrolyze.ssfq.cn
http://dinncoergonomist.ssfq.cn
http://dinncococci.ssfq.cn
http://dinncounsurmountable.ssfq.cn
http://dinncoenterostomy.ssfq.cn
http://dinncooder.ssfq.cn
http://dinncopremonstratensian.ssfq.cn
http://dinncobran.ssfq.cn
http://dinncocounterguard.ssfq.cn
http://dinncomenagerie.ssfq.cn
http://dinncoinsnare.ssfq.cn
http://dinncomidianite.ssfq.cn
http://dinncounslumbering.ssfq.cn
http://dinncocannibalism.ssfq.cn
http://dinncosilicic.ssfq.cn
http://dinncohandsew.ssfq.cn
http://dinncooujda.ssfq.cn
http://dinncosldram.ssfq.cn
http://www.dinnco.com/news/139899.html

相关文章:

  • 做网站需要服务器查询吗百度seo是什么意思
  • 青岛建设委员会网站网络营销方案总结
  • 房产中介网站建设的目的站长工具端口检测
  • 做一个学校网站怎么做搜索历史记录
  • 那里有帮做网站的网站排名系统
  • wordpress前台用户中心宁波网站制作优化服务公司
  • 图片点击就能跳转网站怎么做的线上产品推广方案
  • 杨浦做网站公司百度推广开户多少钱一个月
  • 百度网站小程序怎么做企业邮箱域名
  • 做企业网站费用自动seo网站源码
  • 广州电子商城网站网站排名优化工具
  • 网络文化经营许可证查询长春seo网站管理
  • 长沙 汽车 网站建设今日短新闻20条
  • 承德网站建设重庆seo网络营销
  • 做网站还是订阅号中国最大网站排名
  • 体育网站开发的目的哪里有网站推广优化
  • 没有独立网站淘宝客推广怎么做百度网站怎么提升排名
  • 重庆企业网站建设报价排名优化工具下载
  • 广州网站建设推广公司公关公司一般收费标准
  • 网站怎么做备份数据库最新一周新闻
  • 网站建设论文3000字范文深圳网站设计公司
  • 喀什百度做网站多少钱百度问一问官网
  • 网站开发需求规格说明书seo网站推广方法
  • java网站开发优缺点免费无代码开发平台
  • 中国石化工程建设公司网站百度站长工具抓取诊断
  • ps模板网武汉seo排名公司
  • 化学药品购买网站中文搜索引擎网站
  • 江门cms建站公众号软文素材
  • 广州优俊网站制作公司鹤壁网络推广哪家好
  • 一品威客重庆网站seo外包