标签:bsp 编译器 引用 printf int ons 只读 cpp class
常引用:让变量引用只读属性;
分为两种:用变量初始化的常量引用,和 ,用常量初始化的常量引用
//常量引用初始化 分为两种
//1 用变量 初始化 常量引用
{
int x = 20;
const int& y = x;
printf("y:%d \n", y);
}
//2 用常量 初始化 常量引用
{
//int &m = 10; //引用是内存空间的别名 字面量10没有内存空间 没有方法做引用
const int &m = 10; //c++编译器会偷偷给m分配一个内存空间
}
标签:bsp 编译器 引用 printf int ons 只读 cpp class
原文地址:http://www.cnblogs.com/xiaochige/p/6675003.html