Doubly circular link list implementation I am supposed to be creating a doubly circular linked list, but I am now have problems creating the actual linked list. Is there a problem with the classes? Also, for the assignment, the list is suppose to be a template class, but now I just want to get the code to work. 

#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;iomanip&gt;
#include &lt;stdio.h&gt;  

using namespace std;
//template &lt;class Object&gt;

//template &lt;class Object&gt;
class Node
{   
    //friend ostream&amp; operator&lt;&lt;(ostream&amp; os, const Node&amp;c);
public:
    Node( int d=0);
    void print(){
        cout&lt;&lt;this-&gt;data&lt;&lt;endl;
    }
//private:
    Node* next;
    Node* prev;
    int data;

    friend class LinkList;
};
Node::Node(int d):data(d)
{

}

//template &lt;class Object&gt;
class LinkList
{
void create();
public:
    //LinkList();
    LinkList():head(NULL),tail(NULL),current(NULL)
    {create();}
    int base;
    //LinkList(const LinkList &amp; rhs, const LinkList &amp; lhs);
    ~LinkList(){delete current;}

    const Node&amp; front() const;//element at current
    const Node&amp; back() const;//element following current 
    void move();
    void insert (const Node &amp; a);//add after current
    void remove (const Node &amp;a);
    void print();
private:
    Node* current;//current
    Node* head;
    Node* tail;
};

void LinkList::print()
{
    Node *nodePt =head-&gt;next;
    while(nodePt != head)
    {
        cout&lt;&lt;"print function"&lt;&lt;endl;
        cout&lt;&lt;nodePt-&gt;data&lt;&lt;endl;
        nodePt=nodePt-&gt;next;
    }
}
//element at current

void LinkList::create()
{
    current = head = tail = new Node(0);
    current-&gt;next = current-&gt;prev = current;
}

const Node&amp; LinkList::back()const
{
    return *current;
}
//element after current
const Node&amp; LinkList::front() const
{
    return *current -&gt;next;
}

void LinkList::move()
{
    current = current -&gt;next;
}
//insert after current 
void LinkList :: insert(const Node&amp; a)
{
    Node* newNode= new Node();
    newNode-&gt;prev=current;
    newNode-&gt;next=current-&gt;next;
    newNode-&gt;prev-&gt;next=newNode;
    newNode-&gt;next-&gt;prev=newNode;
    current=newNode;
}
void LinkList::remove(const Node&amp; a)
{
    Node* oldNode;
    oldNode=current;
    oldNode-&gt;prev-&gt;next=oldNode-&gt;next;
    oldNode-&gt;next-&gt;prev=oldNode-&gt;prev;
    delete oldNode;
}

//main file
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;iomanip&gt;
#include &lt;stdio.h&gt;  
#include "LinkedList.h"

using namespace std;

int main()
{
    int n;
    cout&lt;&lt;"How many Nodes would you like to create"&lt;&lt;endl;
    cin&gt;&gt;n;

    LinkList list1 ;

    list1.print();
    for(int loop = 0;loop &lt; n;++loop)
    {
        list1.insert(loop);
    }
    list1.print();
}
You have done the correct thing by putting a sentinel element into the list.
This makes adding/removing and generally manipulating the list trivial because you don't need to handle NULL links in the list. 

But you have done it using a two phase create.  


You have to construct your list.
You have to call create to initialize it.


This is a very bad idea. Your object should be fully constructed at the end of the constructor. That way users can not incorrectly initialize your class.

There is also a bug in your create. You create a node but you don;t link it to anything:

void LinkList::create()
{
   Node start(0);  // This node is destroyed at the end of the function.
}


What you should be doing is:

LinkedList::LinkedList()
    : current(new Node(0, NULL, NULL))
    // , head(current)      You don't actually need head/tail
    // , tail(current)      since it is circular these are beside each other.
{
    current-&gt;prev = current;
    cureent-&gt;next = current;
}


Also your code can delete the sentinel and thus cause all sorts of problems. You should not allow the deletion of the sentinel and your other functions should check for a list with just a sentinel in them (this is the empty list).

Why are you giving back references to the Node? This is an internal implementation detail. Return a reference to the value (or throw an exception if the list is empty). By returning a node you are binding your self to use a specific implementation (take a leaf out of the standard library and just return a reference to the value).

const Node&amp; LinkList::back()const


Same comment again:

const Node&amp; LinkList::front() const


Not sure I have seen this functionality in a list before. It seems to allow you to move the head around inside the list.

void LinkList::move()


So this is why you have to return the node above?

void LinkList :: insert(const Node&amp; a)


I would rather have insert_front/insert_back/insert_at functionality.

Remove has some issues:

void LinkList::remove(const Node&amp; a)


Two problems:


You don't update current (so it points at the deleted node).
You allow the sentinel to be deleted.
If you delete the last node the easy insertion/deletion breaks down.


This is what I would do:

class LL
{
   struct Node {
       int value;
       Node* next;
       Node* prev;
       Node() // Sentinel
         : next(this)
         , prev(this)
       {}
       Node(int val, Node* prev, Node* next)
          : value(val)
          , next(next)
          , prev(prev)
       {
           prev-&gt;next = this;
           next-&gt;prev = this;
       }
       ~Node()
       {
           prev-&gt;next = next;
           next-&gt;prev = prev;
       }
    };
    Node* current;
    LL()
        : current(new Node)
    {}
    ~LL()
    {
        while(!empty())
        {
           delete current-&gt;next;
        }
        delete current;
    }
    bool empty() const { return current == current-&gt;next;}
    void insert_front()
    {
         new Node(current, current-&gt;next);
    }
    void insert_back()
    {
         new Node(current-&gt;prev, current);
    }
    void delete_front()
    {
         if (!empty())
             delete current-&gt;next;
    }
    void delete_back()
    {
         if (!empty())
             delete current-&gt;prev;
    }
    int&amp; front()
    {
        if (empty()) {throw empty_exception();}
        return current-&gt;next-&gt;value;
    }
    int&amp; back()
    {
        if (empty()) {throw empty_exception();}
        return current-&gt;prev-&gt;value;
    }
};