I am trying to read 2 lists and concatenate them overloading + operator. I am pretty new in classes so please be patient with me, all I want is to learn. I overloaded the stream operators so I can read and write the objects normal and reversed . My + operator does concatenate the lists but the problems seems to be in main ( list1=list1+list2; or writing list3 -after concatenating list1 and list2 ). I looked almost everywhere on the internet for an answer and I ended posting this. If you have any links or tutorials that can make me grow faster and easier I am opened to new ideas. Thank alot for reading this and tryng to help ^^
Node Class:
class nod
{
public:
    int data;
    nod *next;
    nod *prev;
    friend class Lista;
    nod();
};
List Class
class Lista
{
private:
    nod *head;
    nod *tail;
    int size;
public:
    Lista();
    ~Lista();
    friend istream &operator >>(istream &input, Lista &a)
    {
        int i;
        cout << "Size of the list: ";
        input >> a.size;
        nod *q = new nod;
        q->prev = NULL;
        cout << "\nFrist node: ";
        input >> q->data;
        a.head = q;
        a.tail = a.head;
        for (i = 1; i < a.size; i++)
        {
            nod *q = new nod;
            cout << "\nNode number " << i + 1 << " is: ";
            input >> q->data;
            a.tail->next = q;
            q->prev = a.tail;
            a.tail = q;
            a.tail->next = NULL;
        }
        return input;
    }
    friend ostream& operator <<(ostream &output, Lista &a)
    {
        output << "\n\nNormal writing: ";
        nod *q = new nod;
        q = a.head;
        while (q != NULL)
        {
            output << q->data << " ";
            q = q->next;
        }
        q = a.tail;
        output << "\n\nReverse writing: ";
        while (q != NULL)
        {
            output << q->data << " ";
            q = q->prev;
        }
        return output;
    }
    Lista &operator+(Lista &rec)
    {
        Lista temp;
        temp.head = head;
        temp.tail = tail;
        temp.tail->next = rec.head;
        rec.head->prev = temp.tail;
        temp.tail = rec.tail;
        temp.size = size;
        temp.size = temp.size + rec.size;
        return temp;
    }
};
Main:
int main()
{
    Lista a,b,c;
    cin>>a;
    cin>>b;
    c=a+b;
    cout<<c;
    return 0;
}
 
     
    