const reference

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了const reference相关的知识,希望对你有一定的参考价值。

void main(){

int a=3;

const int f=4;

//int &g=f;不可把常量赋给int型引用

//int &c=3;不可把常量赋给int型引用

int &b=a;

const int &d=3;//可以给常量引用赋以常量。

const int &e=a;

a++;//a可以修改

//e++;但是定义为常量引用的e就不可以修改。

return ;

}


以上是关于const reference的主要内容,如果未能解决你的问题,请参考以下文章