I am creating a recursive function to reverse a linked list.
class LinkedList {
node *head;
public:
node *reverse(/* Here, I want to pass the head as a default argument */);
}
I have tried to do node *reverse(node *nd = this->head)
but it raises the following error:
'this' may only be used inside a nonstatic member function
Why is this happening? How can I achieve my goal?