I have made a linked list with the following functions.
Code:
class node
{
public:
int data; node* next;
};
class linkedList: public node
{
node* head;
public:
linkedList()
void insertEnd( int data) // Inserts the node at end
void insertStart(int data) // Inserts the node at start
void search(int l) // Searches the data in nodes
void deleteAnode(int l) // Delete any node (expect first or last)
void deleteSNode() // Delete start node
void deleteENode() // Delete end node
Now i want to make a function like which inserts a node in between two nodes.
So I have to take the nodes data , between which i want to add a new node?
Would it be like this ?
Code:
void insertAnywhere( int previous, int next, int new)
{
}
Or is there a better way kindly tell.