2008年11月22日c语言中const用法:C++中const的基础介绍
1、const 引用是指向 const 对象的引用: const int ival = 1024; const int &refVal = ival; // ok: both reference and object are const int &ref2 = ival; // error: non const reference to a const object 可以读取但不能修改 refVal。同理,用 ival 初始化 ref2 也是不合法的。ref2 是普通的非 const 引用,因此可以用来修改 ref2 指向的对象的值。通过 ref...
[阅读全文] [PDF]
1 共1条 分1页