Do we really have to use this->… everytime?
Can we not directly use the private members of the class Queue?
@anushreemahur5 you can directly access the private members of a class through a member function of that class. this-> pointer is just an additional feature you can use. It is not mandatory to use it in C++ unlike some other languages. It is however useful in cases like
void func(int data) {
this->data = data;
}
In such a case where you want the argument name to be same as a data member’s name, then “this” pointer can be useful.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.