加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

为什么C指针中的“this”指针不是引用?

发布时间:2020-12-16 07:53:37 所属栏目:百科 来源:网络整理
导读:为什么这个指针在C中是一个指针而不是引用? 有没有使用我错过的使用“this”作为一个比引用更有用的指针? 如果不是,有没有任何语言设计的含义/考虑作为一个指针? 解决方法 从 Bjarne Stroustrup’s C++ Style and Technique FAQ: Why is “this” not a
为什么这个指针在C中是一个指针而不是引用?

有没有使用我错过的使用“this”作为一个比引用更有用的指针?

如果不是,有没有任何语言设计的含义/考虑作为一个指针?

解决方法

从 Bjarne Stroustrup’s C++ Style and Technique FAQ:

Why is “this” not a reference?

Because “this” was introduced into C++ (really into C with Classes) before references were added. Also,I chose “this” to follow Simula usage,rather than the (later) Smalltalk use of “self”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读