Implementation of a templated Singly linked list class in c++ The code below is my implementation of singly linked list.I would prefer it, if you kindly review the code and give me pointers on how a professional programmer would have written the code. Basically, i want to know about some good code habits that I have missed in the code.

The class one_way_linked_list is the linked list class. It uses the node class to create the nodes of the list. It keeps record of every object's head node using the head pointer. The function list_create() creates the list. The function list_print() prints the code. The function list_delete() deletes the linked list by deallocating every node one by one.

Sorry for my english, as it is not my native language. Thank you in advance. 

#include &lt;iostream&gt;

using namespace std;

template&lt;typename t&gt;
class node
{

public:
    t data;
    node *next;

    //constructors
    node()
    {
        next=NULL;
    }
    node(t d)
    {
        data=d;
        next=NULL;
    }
};

template&lt;typename t&gt;
class one_way_linked_list
{
    node&lt;t&gt; n;
public:
    node&lt;t&gt; *head=NULL;
    node&lt;t&gt; *prev=NULL;

    void list_create(t);
    void list_print();
    void list_delete()
};

template &lt;typename t&gt;
void one_way_linked_list&lt;t&gt;::list_create(t dat)
{
    node&lt;t&gt; *ptr=new node&lt;t&gt;(dat);
    if(head==NULL)
{
    head=ptr;
    prev=head;
}
else
{
    prev-&gt;next=ptr;
    prev=ptr;
}
}

template&lt;typename t&gt;
void one_way_linked_list&lt;t&gt;::list_print()
{
    node&lt;t&gt; *ptr=this-&gt;head;
    cout&lt;&lt;"Printing the list: "&lt;&lt;endl;
    while(ptr!=NULL)
    {
        cout&lt;&lt;ptr-&gt;data&lt;&lt;" ";
        ptr=ptr-&gt;next;
    }
    cout&lt;&lt;endl;
}

template&lt;typename t&gt;
void one_way_linked_list&lt;t&gt;::list_delete()
{
    node&lt;t&gt; *ptr=new node&lt;t&gt;();
    ptr-&gt;data=this-&gt;head-&gt;data;
    while(ptr!=NULL)
    {
        ptr=ptr-&gt;next;
        delete ptr;
    }
    delete this-&gt;head;
    head=NULL;
    cout&lt;&lt;"Deleted"&lt;&lt;endl;
}

int main()
{
    //driver program for int type list
    one_way_linked_list&lt;int&gt; list1;
    int temp;
    while(1)
    {
        cin&gt;&gt;temp;
        if(temp==-1) break;
        else
        {
            list1.list_create(temp);
        }
    }
    list1.list_print();
    list1.list_delete();
    list1.list_print();
}
Advice 1

You can move the definition of node into the declaration body of one_way_linked_list. This allows "inheritting" the type parameter t, and, thus, omitting it altogether in the node.

Advice 2

node(t d)
{
    data=d;
    next=NULL;
}


The more C++ way would be:

node(t d) : data{d}, next{nullptr} {}


Advice 3

Most C++ programmers write the type parameters starting from an uppercase letter. In your case, I suggest you rename t to T in the template declaration.

Advice 4

public:
    node&lt;t&gt; *head=NULL;
    node&lt;t&gt; *prev=NULL;


Here, you expose the implementation details. Move the two under a private:. Also, write nullptr instead of NULL. 

Advice 5 

prev: a better name is tail.

Advice 6

list_create: a better name is add or append.

Advice 7

template&lt;typename t&gt;
void one_way_linked_list&lt;t&gt;::list_delete()
{
    node&lt;t&gt; *ptr=new node&lt;t&gt;();
    ptr-&gt;data=this-&gt;head-&gt;data;
    while(ptr!=NULL)
    {
        ptr=ptr-&gt;next;
        delete ptr;
    }
    delete this-&gt;head;
    head=NULL;
    cout&lt;&lt;"Deleted"&lt;&lt;endl;
}


rewrite as:

node&lt;t&gt;* next;
node&lt;t&gt;* current = head;

while (current) {
    next = current-&gt;next;
    delete current;
    current = next;
}