I am reading something about virtual table. When it comes to pointer __vptr
,
it is stated that by the author
Unlike the
*this
pointer, which is actually a function parameter used by the compiler to resolve self-references,*__vptr
is a real pointer. Consequently, it makes each class object allocated bigger by the size of one pointer.
What does it mean here by saying this
is actually a function parameter? And this
is not a real pointer?
Both pointers are real in the sense that they store an address of something else in memory. By "real" the author means "stored within the class", as opposed to this
pointer, which is passed to member functions without being stored in the object itself. Essentially, the pointer to __vptr
is part of the object, while this
pointer is not.
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