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 ...
随机推荐
- SQL Server 触发器【转】
触发器是一种特殊类型的存储过程,它不同于之前的我们介绍的存储过程.触发器主要是通过事件进行触发被自动调用执行的.而存储过程可以通过存储过程的名称被调用. Ø 什么是触发器 触发器对表进行插入.更新.删 ...
- Charles辅助调试接口
http://blog.sina.com.cn/s/blog_6ae8b50d0102w7tw.html
- Ubuntu 设置Vim tab为四个空格
使用root权限打开 /etc/vim/vimrc 添加下列配置 set tabstop= set softtabstop= set shiftwidth= set noexpandtab set n ...
- android 2.2 videoView 诡异bug
最近遇到一个问题,在2.2系统上,公司项目中使用VideoView,第一次播放正常,第二次播放黑屏. 由于公司项目使用lua + android 原生,所以试了下原生的android 的VideoVi ...
- centos 6.4 安装视频解码器
cd /etc/yum.repos.d/ wget http://mirrors.163.com/.help/CentOS6-Base-163.repo yum update rpm -Uhv htt ...
- sell - 配置service
1. 2. 注意value!
- iOS ASIHTTPRequest 使用指南
http://www.devdiv.com/iOS_iPhone-ASIHTTPRequest使用指南---_lt__lt_翻译稿_gt__gt_---连载-thread-93741-1-1.html
- SendEmail语法
SendEmail语法 示例: /usr/local/bin/sendEmail -f shengwei.tang@joy4you.com -t @qq.com -s smtp.exmail.qq.c ...
- MOGRE学习笔记(2) - MOGRE基础知识总结
前一篇配置了MOGRE的运行环境,这里记录一些MOGRE基础知识,仅仅是最基础的一些东西.由于本人接触ogre的时间比较短,对于很多知识都是一知半解,所以理解起来不免会有一些错误,本人也希望自己在对o ...
- ionic build android 报错分析