码迷,mamicode.com
首页 > 编程语言 > 详细

C++ const常量和指针

时间:2018-02-02 14:29:20      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:ons   art   实验   证明   earth   地址   amp   style   不可   

1    const int g_earth = 9.8;
2     const int * pe = &g_earth;  //可行
3 
4     const int g_moon = 1.3;
5     int * pm = &g_moon;  //不可行

 

实验证明:c++中禁止将const常量的地址赋给非const的指针。

C++ const常量和指针

标签:ons   art   实验   证明   earth   地址   amp   style   不可   

原文地址:https://www.cnblogs.com/hangaozu/p/8404180.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!