Doubly linked list C++ To become more familiar with templates I attempted a doubly linked list implementation in C++. Is this a valid use for a template?

template &lt;class T&gt;
struct LinkedListNode {
    LinkedListNode&lt;T&gt;* m_previous;
    T m_data;
    LinkedListNode&lt;T&gt;* m_next;
};

template &lt;class T&gt;
class LinkedList {
public:
    LinkedList() {
        m_head = nullptr;
    }

    LinkedListNode&lt;T&gt;* m_head;

    void InsertEnd(T data);
    void InsertFront(T data);

};

template&lt;class T&gt;
inline void LinkedList&lt;T&gt;::InsertFront(T data)
{
    LinkedListNode&lt;T&gt;* insertedNode = new LinkedListNode&lt;T&gt;();
    LinkedListNode&lt;T&gt;* firstNode = m_head;

    if (!firstNode) {
        insertedNode-&gt;m_data = data;
        insertedNode-&gt;m_next = nullptr;
        insertedNode-&gt;m_previous = nullptr;
        m_head = insertedNode;
    }
    else {
        while (firstNode-&gt;m_previous != nullptr) {
            firstNode = firstNode-&gt;m_previous;
        }

        insertedNode-&gt;m_next = firstNode;
        insertedNode-&gt;m_previous = nullptr;
        insertedNode-&gt;m_data = data;

        firstNode-&gt;m_previous = insertedNode;

        m_head = insertedNode;
    }

}


template&lt;class T&gt;
inline void LinkedList&lt;T&gt;::InsertEnd(T data)
{
    LinkedListNode&lt;T&gt;* insertedNode = new LinkedListNode&lt;T&gt;();
    LinkedListNode&lt;T&gt;* lastNode = m_head;

    if (!lastNode) {
        insertedNode-&gt;m_data = data;
        insertedNode-&gt;m_next = nullptr;
        insertedNode-&gt;m_previous = nullptr;
        m_head = insertedNode;

    }
    else {
        while (lastNode-&gt;m_next != nullptr) {
            lastNode = lastNode-&gt;m_next;
        }


        lastNode-&gt;m_next = insertedNode;

        insertedNode-&gt;m_previous = lastNode;
        insertedNode-&gt;m_next = nullptr;
        insertedNode-&gt;m_data = data;
        m_head = insertedNode;
    }
}


main.cpp

LinkedList&lt;int&gt;* linkedList = new LinkedList&lt;int&gt;();
linkedList-&gt;InsertEnd(2);
linkedList-&gt;InsertEnd(5);
linkedList-&gt;InsertEnd(9);
linkedList-&gt;InsertFront(1);
linkedList-&gt;InsertEnd(10);

LinkedList&lt;std::string&gt;* stringList = new LinkedList&lt;std::string&gt;();
stringList-&gt;InsertFront("one");
stringList-&gt;InsertEnd("two");
stringList-&gt;InsertFront("three");


Ordering should be
linkedList
1,2,5,9,10
stringList
three,one,two
The biggest thing I can say about your code is don't use raw pointers, start getting into the habit of using smart pointers.


  Smart pointers enable automatic, exception-safe, object lifetime management.