i need to know the code for insert in middle, and this is what i wrote, i dont get any errors so theres some logic error in it, so please help me by giving me the correct code.
void List::insertATMiddle(const string x)
{
Node* p = new Node;
p->setData(x);
p->setNext(NULL);
Node* q;
q = head;
if ((q->getNext() != NULL ) && (q->getData() != x))
{
q = q->getNext();
}
q->setNext(p);
}