Frequently cited points two points:
1 Initializing a const reference with a variable const int &a = b
2 Use literal constant Initialization Const Reference const int &m = ten;
#include <iostream>using namespace std;void main () { //Normal reference int a = 10; int &b = a; printf ("B"%d\n ", b); / /oft-quoted int x = 20; const int &y = x; //frequently quoted function: Let variables have read-only properties ; that cannot be modified by y x //commonly referenced initialization is divided into 2 cases //(1) with variables initialization oft-referenced { int x1 = 30; const int &y1 = x1;//using x1 variable to initialize constant reference } //(2) Literals initialization constant reference { const int a = 40; int &m = 41; //General reference reference a literal Do you have any memory address for the literal number? Answer: No //Compile Error const int &m = 43;//c++ compiler allocates memory space }}
3 Const Reference Conclusion:
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/8C/F6/wKiom1h_Yf2jamUmAAE2ERQUed4997.png "title=" Const references the conclusion. png "alt=" Wkiom1h_yf2jamumaae2erqued4997.png "/>
This article is from the "11907685" blog, please be sure to keep this source http://11917685.blog.51cto.com/11907685/1893026
Reference topic (cont.) = "constant Reference"