当前位置:网站首页>关于this指针
关于this指针
2022-07-23 06:35:00 【c.Coder】
this指针的功能:即在非静态成员函数调用时,可以更准确的访问到实例化对象中的成员属性this指针的类型:类的类型* const,const直接修饰指针本身,即this指针本身的指向不能被改变非静态成员函数不具备该隐藏参数(this指针),因为静态成员函数并不具体属于哪个对象,故其没有指向某个对象的this指针this指针本质上是非静态成员函数的第一个形参(被隐藏的),当对象调用成员函数时,才将对象地址作为实参传递给“this”形参,所以对象中并不存储this指针。
ps:一般情况下(在vs环境下)是由编译器通过ecx寄存器自动传递,无需用户传递
由于this指针是作为实参传递的,所以this指针都是存储在栈空间中。
当非静态成员函数被调用时,如果函数内部并不涉及到对象内的具体成员属性则this指针可以为空,即“this = nullptr”
边栏推荐
猜你喜欢

Beifu PLC and C transmit int type variables through ads communication

Netease white hat hacker training camp notes (2)

云解决方案,为什么选择 AMD EPYC?

0722~ thread pool extension

When using fastjson to parse and assign JSON data, the order of JSON fields is inconsistent

Evaluation of classification model

"100 Android interview questions" I brushed angrily for Dachang

Beifu PLC and C transmit string array type variables through ads communication
![[jzof] 07 rebuild binary tree](/img/c8/5b67a3921afda5323b0d1eea6a78bc.png)
[jzof] 07 rebuild binary tree

Outlook tutorial, how to switch calendar views and create meetings in outlook?
随机推荐
2022-07-22 回顾链表操作以及部分问题
PHP connecting to SQL Server
[visual scheduling software] Shanghai daoning brings netronic downloads, trials and tutorials to SMB organizations
[daily training] 814. Binary tree pruning
keepalived双机热备
Notes on the seventh day
NFT 交易市场的格局之变:从一家独大到百家争鸣
给1万帧视频做目标分割,显存占用还不到1.4GB | ECCV2022
[noi simulation race] I don't know which CF paper title it is (probability expectation, martingale's stop time theorem)
第十天笔记
【可視化調度軟件】上海道寧為SMB組織帶來NETRONIC下載、試用、教程
Shooting games lesson 1-2: using sprites
[jzof] path in matrix 12
深入理解微信小程序的底层框架(一)
[jzof] 07 rebuild binary tree
php连接sql server
【可视化调度软件】上海道宁为SMB组织带来NETRONIC下载、试用、教程
倍福PLC和C#通过ADS通信传输String数组类型变量
太空射击 Part 2-3: 子弹与敌人碰撞处理
Wu Enda machine learning series p31~p42