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
thisnot a reference?Because
thiswas introduced into C++ (really into C with Classes) before references were added. Also, I chosethisto 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