大龙的博客

常用链接

统计

最新评论

用const限定引用的问题

有下例程序段: cosnt int a=123; const int* pa=&a; const int*& ra=pa; //ok const int*& ra=&a; //error const int* const& ra=&a;//ok const int*& const ra=&a;//error; 请问各位高手,为什么第三行是对的,第四行却是错的? 还有第四行中的ra表示的是什么意思,为什么const要放在&前面? 答: const int*& ra=&a; //error const int* const& ra=&a;//ok ★ &a的类型是const int * const const int*& const ra=&a;//error; ★ const对&的修饰是无效的所以const int*& const等价于const int*&

posted on 2010-04-06 23:04 大龙 阅读(147) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理