2012年11月29日

C++ 编程思想——常量

摘要: 1、应该完全用const取代#define的值替代。2、C++中的const默认为内部连接。 ( C默认const是外部连接的。如果在C++中想达到外部连接,必须用extern。 ) 就是说,const仅在const被定义过的文件里才是可见的,而在连接时不能被其它编译单元看见。 否则由于众多的const在多个cpp文件内分配存储,容易引起连接错误。3、常量指针: const int * x; 指针常量: int * const x = &d; 常量对象: const int * const x = &d; or int const * const x = &d; ( 指 阅读全文

posted @ 2012-11-29 21:50 至柔 阅读(156) 评论(0) 推荐(0)

导航