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

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

Reference:alias

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

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宜兴市| 德清县| 原阳县| 香格里拉县| 哈密市| 阿坝| 冕宁县| 揭东县| 城步| 喀喇| 金昌市| 武安市| 讷河市| 肥西县| 将乐县| 虞城县| 穆棱市| 疏勒县| 林周县| 延庆县| 施秉县| 青阳县| 云林县| 汝南县| 合阳县| 西乡县| 科技| 灵丘县| 青田县| 邯郸市| 大化| 盐源县| 即墨市| 辰溪县| 邵东县| 登封市| 新竹市| 温州市| 阆中市| 新源县| 抚宁县|