What does this-> do?
Course: Competitive Programming in C++: The Keys to Success - Learn Interactively
Lesson: Singly Linked List - Searching - Competitive Programming in C++: The Keys to Success
What does this-> do?
Course: Competitive Programming in C++: The Keys to Success - Learn Interactively
Lesson: Singly Linked List - Searching - Competitive Programming in C++: The Keys to Success
Hello Hao,
this->
is a pointer in C++ that points towards the value stored in a parameter in class.
For example,
Node (int val) {
this->val = val;
this->next = NULL;
}
In code above, this->val
is pointing towards the value to be stored in variable val
, which is val
.