2014年5月7日
摘要: 1.在typedef中使用指针往往会带来意外的结果。如下:typedef string *pstring;const pstring cstr;绝大数人刚开始都会认为cstr是一种指针,它指向const对象,即const pstring cstr 等价于const string *cstr,其实,这... 阅读全文
posted @ 2014-05-07 16:43 运动和行动 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 在C++中const变量定义时必须进行初始化,否则无法通过编译。初始化的方式有多种,可以通过字面值对其进行初始化,也可以通过变量对其初始化,或其他方式,只要能给const变量赋初值即可(当然初值应该有其意义)。例:int i = -1;const int ic1 = -1;const int ic2... 阅读全文
posted @ 2014-05-07 15:41 运动和行动 阅读(3619) 评论(0) 推荐(0) 编辑