标签:style class blog c code tar
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie
char greeting[] = “Hello”; char *p = greeting; //non-const pointer, non-const data const char *p = greeting; //non-const pointer, const data char *const p = greeting; //const pointer, non-const data const char *const p = greeting //const pointer, const data
std::vector<int> vec; const std::vector<int>::iterator iter = vec.begin(); //iter的作用像个T *const *iter = 10 //ok. 改变iter所指物 ++iter; //error. iter是const const std::vector<int>::const_iterator cIter = vec.begin(); //cIter的作用像个const T * *cIter = 10 //error. *cIter是const ++cIter; //error. 改变cIter
class Rational {…}; const Rational::operator *(const Rational *lhs, const Rational *rhs) const参数声明为const,避免它修改
Effective C++ Item 3 尽可能使用const,布布扣,bubuko.com
Effective C++ Item 3 尽可能使用const
标签:style class blog c code tar
原文地址:http://blog.csdn.net/zhengsenlie/article/details/26621179