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

首頁 > 學院 > 開發設計 > 正文

Reference:alias

2019-11-11 06:34:06
字體:
來源:轉載
供稿:網友

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;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 元江| 兰州市| 威海市| 和硕县| 海宁市| 泗洪县| 仙游县| 宣武区| 巴楚县| 手机| 双辽市| 辽源市| 宽城| 富民县| 宿迁市| 班戈县| 宜丰县| 西吉县| 石首市| 五台县| 南康市| 万荣县| 长丰县| 建瓯市| 高密市| 佛冈县| 天峨县| 康定县| 竹山县| 大同市| 鄯善县| 广昌县| 沙湾县| 湖北省| 白城市| 赤壁市| 微山县| 青岛市| 灵石县| 定兴县| 白城市|