Hey i want to know how to make my single linked list a double can anyone help?

#include "MyLinkedList.h"
#include <iostream>

int main()
{
    SListNode<int>* list = new SListNode<int>;
    //Set 3 LinkedList nodes to contain 3 int variables.
    list->m_data = 10;//(1).
    list->m_next = new SListNode<int>;
    list->m_next->m_data = 20;//(2).
    list->m_next->m_next = new SListNode<int>;
    list->m_next->m_next->m_data = 30;//(3).
    //Print out the LinkedList.
    std::cout << "list = { ";
    std::cout << list->m_data << ", ";
    std::cout << list->m_next->m_data << ", ";
    std::cout << list->m_next->m_next->m_data << " }" << std::endl;

    list->insertAfter(15);
    list->m_next->m_next->insertAfter(25);

    std::cout << "list = { ";
    std::cout << list->m_data << ", ";
    std::cout << list->m_next->m_data << ", ";
    std::cout << list->m_next->m_next->m_data << ", ";
    std::cout << list->m_next->m_next->m_next->m_data << ", ";
    std::cout << list->m_next->m_next->m_next->m_next->m_data << " }" << std::endl;

    SListNode<int>* iterator = list;

    //print first (10)
    std::cout << "list[0] = " << iterator->m_data << std::endl;
    //skip to third (25) and print it
    for(int i = 0; i < 3; i++)
        iterator = iterator->m_next;
    std::cout << "list[3] = " << iterator->m_data << std::endl;
    getchar();
    getchar();
}

//Declaring a Template.
template<class Datatype>
class SListNode
{
public:
//********Member Variables********
    Datatype m_data;
    SListNode<Datatype>* m_next;
//*********Methods********

//Insert Method.
    void insertAfter(Datatype p_data)
    {
    //Create the new node.
    SListNode<Datatype>* newnode = new SListNode<Datatype>;
    newnode->m_data = p_data;
    //Make the new node point to the next node.
    newnode->m_next = m_next;
    //Make the previous node point to the new node.
    m_next = newnode;
    }
};

This should get you started:

template<class Datatype>
class DListNode
{
public:
    //********Member Variables********
    Datatype m_data;
    DListNode<Datatype>* m_prev;
    DListNode<Datatype>* m_next;
    //*********Methods********
    ...
};
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.