Intersection point two linked list

Pls rectify my code and tell me my mistakes as it is giving segmentation error(core dumped).
code: https://ide.codingblocks.com/s/194391

There is no need to make two separate classes as both linked lists are of the same type.

But can my code be rectified to answer the question?

Using 2 classes for both linked lists…

I am not able to understand how can a single class be used for 2 seperate inputs of different sizes…Pls explain

We never create separate classes like you have done.
Try to solve this question using the common class given below -
class node
{
public:
int data;
node *next;

    node()
    {
        data = -1;
        next=NULL;
    }

};


Check this code and tell me if you are able to understand it.

Yes.I am able to understand how it works.Thanks.