Single Linked List - Improvements - 1 - not complete
/* C++ Version - lnode, lnode_reverse, lnode_push, lnode_print, lnode_count
   I need node_type turned into a templated class..How does one do this?
*/
typedef struct node_type 
  { 
  int data; 
  struct node_type* next; 
  } lnode_type;


Turning it into a template is pretty straightforward:

template &lt;class T&gt;
class node_type { 
   T data;
   node_type *next;
};


Note that the typedef isn't really necessary (or desirable) in C++. You normally just want to use class whatever, and then the body of the class definition. This makes whatever usable as a name by itself, just about like the typedef would in C.

There's one other thing we probably want to do though: the whole basic idea of a linked-list node is really just an implementation detail of the linked list, so we really want to make the node type a nested class inside of the linked-list class:

template &lt;class T&gt;
class sl_list {

    struct node {
        T data;
        node *next;
    } head;

public:
    // Other stuff here.
};


From there, we want to write the functions that work with the data type to use T instead of int. For example, instead of your push(int), you might write something like this:

void push(T data) {
  ++count; // prefer pre-increment when you don't need the old value.
  node* newNode = new node; 
  newNode-&gt;data = data;
  newNode-&gt;next = head;
  head = newNode; 
}


We might prefer to add a ctor to the node class/struct, something like this:

node(T data, node *next = NULL) : data(data), next(next) {}


With that, push becomes something like this:

void push(T data) { 
    node *newNode = new node(data, head);
    ++count;
    head = newNode;
}


[Edit2: Note that, as recommended by @LokiAstari, I've also moved the ++count to after allocating the new node. This way if the attempted allocation fails (and new throws an exception), count will not be incremented, so it retains the correct values. If and only if the allocation succeeds, it's incremented to reflect the new node having been added to the list. ]

[Edit: and node would look roughly like this:

    struct node {
        T data;
        node *next;

        node(T data, node *next = NULL) : data(data), next(next) {}            
    } head;


]