国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Reference:alias

2019-11-11 07:07:19
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

Rule:

1.References must be initialized when de?ned. Initialization establishes a binding.

eg: type& refname = name; //thus the value of refname is the same as name.

2.Bindings don’t change at run time, unlike pointers.

3.The target of a reference must have a location! 

 eg:void func(int &); //automatically binding when call the function.

func(i*3); //warning or error!

 Restrictions:

1.No references to refercences

2.No pointers to references

int & * p; //illegal

  But reference to pointer is ok

int* & p;

3.No arrays of reference

Notice: constant value can be modified through reference.

#include <iostream>using namespace std;int main(){    int& *p;    int x=3;    int &y=x;    const int&z=x;    cout<<"z:"<<z<<endl;    y=4;    cout<<"after y=4,z:"<<z<<endl;    x=5;    cout<<"after x=5,z:"<<z<<endl;//error here:z cannot be assigned,but it still can be modified by y or x.//  z=5;    return 0;}


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 麟游县| 察隅县| 孝感市| 钟山县| 青神县| 兴业县| 五原县| 怀集县| 常山县| 高青县| 铜梁县| 塔城市| 秀山| 交口县| 乌兰察布市| 延安市| 拜城县| 桑日县| 武强县| 大关县| 太康县| 马边| 呼伦贝尔市| 勃利县| 竹溪县| 蒙自县| 获嘉县| 革吉县| 茶陵县| 虎林市| 无锡市| 晋城| 巍山| 白朗县| 宁国市| 台江县| 阿瓦提县| 宁晋县| 方正县| 鄂托克前旗| 尼玛县|