0
Does this pointer not a lvalue reference?
Hi We cannot modify this pointer inside a member function something like below : void changePtr(T* p) { this = p; } Is it something c++ has not allowed to change pointer? Any specific reason for blocking the behaviour?
4 Answers
+ 2
Yeah true... I don't have use case and it's not something I gonna do also..this is one of the question in Sololearn challenge and make me think why it has been set as rvalue
0
We have const specifier for member function... Function argument can be set as const by keyword before data type... Member function const means this pointer is aslo const... Does this not enough to block one making someone change this pointer ? Is it necessary to have it as rvalue ?