国产探花免费观看_亚洲丰满少妇自慰呻吟_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;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 浙江省| 民乐县| 涿州市| 新竹县| 勐海县| 德格县| 潮安县| 班玛县| 闵行区| 汝城县| 交城县| 延津县| 上蔡县| 册亨县| 衡东县| 泰安市| 溧阳市| 扎鲁特旗| 安平县| 彭州市| 文水县| 淮南市| 油尖旺区| 文登市| 胶州市| 南部县| 芒康县| 南木林县| 白山市| 乌兰浩特市| 嘉定区| 辛集市| 棋牌| 安康市| 大竹县| 军事| 云林县| 无极县| 陵川县| 观塘区| 五原县|