Why is the this
pointer in C++ a pointer and not a reference?
Are there use-cases that I'm missing that make "this" as a pointer more useful than a reference?
If not, are there any language design implications/considerations involved in having it as a pointer?
From 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 chosethis
to follow Simula usage, rather than the (later) Smalltalk use ofself
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With