//two usages of const-modified references#include <iostream>using namespacestd;structteacher{Charname[ -]; intAge ;};voidSetA (ConstTeacher &T1) { //t1.age = 13; //Error C3490: cannot be modified because "age" is being accessed through a const object}voidMain () {//The first way to useTeacher t; T.age= A; SetA (t); //The second way to use//int &b = 10; //Error Error C2440: "Initialize": Cannot convert from "int" to "int &"//because the reference is essentially a constant pointer cannot take the address of the literal 10, error Const int&b =Ten; //When a const reference is initialized with a constant (literal), the C + + compiler allocates a memory space for the constant value,//and assigns the address of the memory space to the reference//B = 11; //Error C3892: "B": Cannot assign a value to a constantSystem"Pause");}
C + + const keyword Decoration reference