你能解释一下这个指针的概念吗? [英] Can you explain the concept of the this pointer?
本文介绍了你能解释一下这个指针的概念吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要理解这个
指针概念,最好用一个例子。
所以请使用简单的语言,这样我就可以更好的理解了。
解决方案
此
是指向其类的实例的指针
如果你已经声明了一个类,它有一个私有成员 foo
bar
可通过 bar
, foo
code> this-> foo ,但不通过 instance-> foo
b
I need to understand this
pointer concept, preferably with an example.
I am new to C++, so please use simple language, so that I can understand it better.
解决方案
this
is a pointer to an instance of its class and available to all non-static member functions.
If you have declared a class, which has a private member foo
and a method bar
, foo
is available to bar
via this->foo
but not to "outsiders" via instance->foo
.
这篇关于你能解释一下这个指针的概念吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文