摘要: 1.指针和const 指针是c/c++中重要的一部分,但是指针一旦跟const相关联就很容易使人困惑。我们常听任说指针常量和常量指针,那他们有什么区别呢?我们从下面简单的例子入手来讲解下。 1 int a=10; 2 const int *pa1=&a; 3 int const *pa2=&a; 4 int *const pa3=&a; 5 const int *const pa4=&a; 其实上面的例子中2和3的效果是一样的,const修饰的是*pa,也就是说const修饰的是指针指向的内容,这样的话我们通过指针是无法修改a的值得,这种... 阅读全文
posted @ 2011-12-19 20:19 渔牧 阅读(134) 评论(0) 推荐(0) 编辑