const修饰
const int A() //const // ====>int A(const this)
{
//观点1:const是修饰a,但是通过测试,我们发现,b++也不能编译通过
//这说明:const把a 和 b都修饰了。。。。
//剖析:因为this作为函数的第一个参数,被隐藏。。。。const没有地方放。。。。
//
//const是修饰this
a ++;
//b++;
return a;
}
const修饰的更多相关文章
- [转载]能不能同时用static和const修饰类的成员函数?
题目(一):我们可以用static修饰一个类的成员函数,也可以用const修饰类的成员函数(写在函数的最后表示不能修改成员变量,不是指写在前面表示返回值为常量).请问:能不能同时用static和con ...
- C++中 容易忽视的const 修饰符
C++可以用const定义常量,也可以用#define定义常量,但是前者比后者有更多的有点: (1)const常量有数据类型,而宏常量没有数据类型.编译器可以对const进行类型安全检查,而后者只进行 ...
- const 修饰函数
At the very first ,I got a problem . Vector Vector::operator+(const Vector &v)const{ return Vect ...
- [Reprint]C++函数前和函数后加const修饰符区别
c++中关于const的用法有很多,const既可以修饰变量,也可以函数,不同的环境下,是有不同的含义.今天来讲讲const加在函数前和函数后面的区别.比如: 01 #include<iostr ...
- const修饰虚函数
[1]程序1 #include <iostream> using namespace std; class Base { public: ; }; class Test : public ...
- C++函数前和函数后加const修饰符区别
class Test(){ public: Test(){} const int foo(int a); const int foo(int a) const; }; 一.概念 当const在函数名前 ...
- const修饰指针
关于const修饰指针的情况,一般分为如下4种情况: ; const int *a =&b; //情况1 int const *a =&b; //情况2 int* const a =& ...
- const修饰的双重指针赋值解惑
在c程序中,我们可能经常会使用到指针之间的赋值. 传统的赋值操作: char *cp = "c"; const char *ccp; ccp = cp; printf(" ...
- C++ const修饰函数、函数参数、函数返回值
const修饰函数 在类中将成员函数修饰为const表明在该函数体内,不能修改对象的数据成员而且不能调用非const函数.为什么不能调用非const函数?因为非const函数可能修改数据成员,cons ...
- C++中const修饰基本数据类型、指针、引用、对象
const修饰基本数据类型 #include <iostream> using namespace std; void main(){ const int a = 1; const cha ...
随机推荐
- NRF51822之app_button使用
我们现在开始使用app_button,为什么要使用这个来替代直接使用GPIOTE呢? 因为我们在手册中可以看到如果一直开启GPIOTE in模式的需要需要很大电流.所以我们需要使用RTC来“周期”的查 ...
- Python的深拷贝与浅拷贝
一.前奏:熟悉Python内存管理 在Python中,变量在第一次赋值时自动声明,在创建—也就是赋值的时候,解释器会根据语法和右侧的操作数来决定新对象的类型. 引用计数器:一个内部跟踪变量 引用计数: ...
- HIVE中的HQL操作
1.字段查询 select empno,ename from emp; 2.过滤where,limit,distinct select * from emp where sal >2500; s ...
- TCP的三次握手四次挥手
一.三次握手 1.wireshark 抓包 2.TCP报文手部 注意标志位: 1).同步 SYN = 1 表示这是一个连接请求或连接接受报文. 2).只有当 ACK = 1 时确认号字段才有效.当 A ...
- Qt调用dll中的功能函数
声明: 事先我已经自己动手写了一个简单的dll文件(myDLL.dll),C版接口的.并且用我前两篇有关DLL文章里面的方法,从dll中导出了导入库(.lib)文件,dll中有两个函数,原型如下: ...
- SQL Server存储机制二
http://blog.csdn.net/ltylove2007/article/details/21084585 http://www.cnblogs.com/anding/p/3254674.ht ...
- android监听屏幕打开关闭广播无响应的情况
android在屏幕打开和关闭的时候会发出广播,但是如果receiver配置在AndroidManifest.xml中时,receiver是接受不到任何广播的. <receiver androi ...
- Search in Rotated Sorted Array I
Search in Rotated Sorted Array I Suppose a sorted array is rotated at some pivot unknown to you befo ...
- 12 Tips for Accurate Project Estimating
Projects typically involve many dynamic aspects, yet they're often constrained by finite conditions. ...
- hexo 搭建博客
使用hexo搭建网站.记录一下. hexo搭建方法: https://wsgzao.github.io/post/hexo-guide/ http://jacob110.github.io/2015/ ...