Normall const variable:
Your can’t change it even if you defined a variable as a const
Int const x = 2 or const int x = 2
Const object :
Const Dog mimi or Dog const mimi
Const pointer and refer
char * const prt1 = string prt1; ---- a const pointer to a string
it is wrong that give prt1 the value like ptr1 = string prst2 , you can use *prt1 = “m”
but
const * ptr2 = string prt1;
*prt2 = “x” is wrong prst2 = stirng prt1 is ok
const double & v;
Const function :
Only constf function can operate const variable
void R::print() const
{
cout<<R1<<";"<<R2<<ENDL;
}
分享到:
相关推荐
const在C++中占有重要作用,属于小兵立大功的典型,本文档详细介绍了如何使用const
C++ learning ---const用法总结,将平时不同情况的const用法,进行了详细的总结。是学习C++的好帮手
一 const基础;二 const的初始化;三 作为参数和返回值的const修饰符;四 类成员函数中const的使用;五 使用const的一些建议。
C++中const关键字详解
C++中const使用说明。。。C++中const使用说明。。。
本文给大家介绍了C++中的const限定修饰符。
关于const在C++中的用法,绝对有意义的总结!
C++函数后加Const关键字的意义。C++类中经常会看到某函数后面加Const关键字,该文档说明了这些Const关键的意义和用法。
C++ 中const总结 const 限定符把一个对象转换成一个常量,如 const int bufSize=512; 申 明 bufSize 的时候,如果不将它初始化,那么编译器会报错:const object must be initialized if not extern。因为 bufSize ...
Const用法详解 C++ const用法非常灵活,正确使用灵活使用是开法人员非常有好处。
const C++/C 面试题 数据结构 面试题集共享啦
文件有对const修饰普通变量、指针、函数等等的详细解释,是对c++中const用法的完整总结。
const_用法总结(C++)文档
C++里对const的常用用法和总结,很不错,讲的很详细。
C++中const关键字详解
关于C++开发思想的一本经典之作 目 录 译者序 前言 第1章 对象的演化 1 1.1 基本概念 1 1.1.1 对象:特性+行为 1 1.1.2 继承:类型关系 1 1.1.3 多态性 2 1.1.4 操作概念:OOP程序像什么 3 1.2 为什么C++会成功 3 ...
在头文件的类的定义中定义了一个const成员变量c++ 规则: 1、类定义中不能进行初始化,因为头文件中类的定义只是一个声明,并没有分配真正空间,因此变量是不存在的,因此是不能赋值的。 2、const 定义的变量是不能...
C++ Const 思考 误区 新手的福音
浅谈C++中的几个关键字static,const,inline.doc 浅谈C++中的几个关键字static,const,inline.doc
本文档详细介绍了C++中关键字const的用法,并给出了具体的示例来帮助读者理解