- int a=1;
- const int b=4;
- int& ref_a;//必须初始化 :declared as reference but not initialized
- const int& ref_a_const=a;
- ref_a++;
- ref_a_const++;//只读的:increment of read-only reference ‘ref_a_const’
- int& ref_b=b;//类型不匹配: invalid initialization of reference of type ‘int&’ from expression of type ‘const int’
- const int& ref_b_const=b;
- //该片段来自于http://www.codesnippet.cn/detail/280120131956.html
来源: http://www.codesnippet.cn/detail/280120131956.html