Whats correct way to overload + operator inl inked list

Im doing it this way whats wrong

class Node{

public:
    int data;
    Node *next;

Node(int n){
    data=n;
    next=NULL;
}

friend Node* operator+(Node* &, Node* &);

};

Node* addLists(Nodehead1, Nodehead2){

if(head2==NULL)return head1;
if(head1==NULL)return head2;


Node *temp = head1;
while(temp->next!=NULL){
    temp=temp->next;
}
temp->next = head2;

return head1;

}

Node* operator+(Node*&head1, Node*&head2){

head1 = addLists(head1,head2);
return head1;

}

Share your code using ide.codingblocks.com
I will let you know what issue you are facing with this code.

To overload + you have to make a new class and then you have to overload your + operation
Check it here, you can see the implementation
https://www.dreamincode.net/forums/topic/330309-concatenation-linkedlist-using-operator-overloading/
Friend function won’t work in this case.

please can you check it

It’s simple just edit your code as per this code i have given. If Still not able to do it. Let me know. Will help you with the same.

please suggest changes in my code

I dont know much …

Okay wait, let me do it . Have replied to you in chat. You can see.

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.