In C++, why isn't the this keyword a reference? [duplicate]
Possible Duplicate:
W开发者_JAVA技巧hy ‘this’ is a pointer and not a reference?
Is there a good reason that this
is a pointer instead of a reference in C++?
The this
concept was introduced before the reference concept was. At the time, this
had to be a pointer.Source
From Stroustrup's FAQ
http://www2.research.att.com/~bs/bs_faq2.html#this
As crazy as it sounds it is actually legal to delete this;
. Sometimes it is even warranted, but very rarely.
精彩评论