Would making 'this' a reference rather than a pointer be better in retrospect? [duplicate]
Possible Duplicate:
Why ‘this’ is a pointer and not a reference?
Is there any reason for this
in C++ to be a pointer rather than a reference other than historical language decision? It feels a tad strange given that e.g. copy constructor or assignment operators both开发者_如何学运维 accept reference to "that
", not a pointer.
[I honestly couldn't find this question, though it does feel like a possible duplicate]
From Bjarne Stroustrup's "The Design and Evolution of C++", Addison-Wesley, 1994, pp 39-40:
Sometimes, people ask why
this
is a pointer rather than a reference and why it is calledthis
rather thanself
. Whenthis
was introduced into C with Classes, the language didn't have references, and C++ borrows its terminology from Simula rather than Smalltalk.
References didn't exist in the language when this
was created.
精彩评论