Why am I getting "cannot convert from Dequeu<int> to int" error? : <p>I am currently trying to write my first template class as an assignment for my c++ class, but I don't understand why I keep getting this error:</p>

<pre><code>g++ -c main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:12:14: error: cannot convert ‘Dequeu&lt;int&gt;’ to ‘int’ in initialization
  int ou = i[0];
</code></pre>

<p>main.cpp:</p>

<pre><code>#include "main.h"
#include &lt;stdio.h&gt;
#include &lt;iostream&gt;

using namespace std;
int main (int args, char ** argc){

    Dequeu&lt;int&gt;* i = new Dequeu&lt;int&gt;();

    i-&gt;push_back (10);

    int ou = i[0];

    cout&lt;&lt;"i[0]: "&lt;&lt;ou&lt;&lt;endl;
}
</code></pre>

<p>with main.h:</p>

<pre><code>#include "Dequeu.h"
</code></pre>

<p>dequeu.h:</p>

<pre><code>#ifndef MAIN_H
#define MAIN_H
#endif

#include "Node.h"
#include &lt;stddef.h&gt; //NULL

template&lt;typename T&gt;
class Dequeu {
public:
    Dequeu();   ~Dequeu();

    void push_back(T);

    T &amp;operator[] (int i) {
        if (i&lt;size &amp;&amp; i&gt;=0){

            //head?
            if (i == 0)
                return head-&gt;value;
            //tail?
            if (i == size-1)
                return tail-&gt;value;

            //other:
            Node&lt;T&gt;* temp = head;
            i--;

            while (i != 0 ){
                temp = temp-&gt;next;
                i--;
            }

            return temp-&gt;Value();
        }
    }

private:
    Node&lt;T&gt; * head;
    Node&lt;T&gt; * tail;
    int size;
};

template&lt;typename T&gt;
Dequeu&lt;T&gt;::Dequeu() {
    head-&gt;nullify();
    tail-&gt;nullify();
}

template&lt;typename T&gt;
Dequeu&lt;T&gt;::~Dequeu(){
    Node&lt;T&gt;* temp = head;

    while (temp-&gt;Next() != NULL) {
        temp = temp-&gt;next;
        delete(head);
        head=temp;
    }
}

template&lt;typename T&gt;
void Dequeu&lt;T&gt;::push_back(T t){
    Node&lt;T&gt;* newNode;

    newNode-&gt;Value(t);
    newNode-&gt;prev = tail;

    tail-&gt;next = newNode;
    tail = newNode;

    if (head == NULL)
        head = tail;

    size++;
}
</code></pre>

<p>and Node.h:</p>

<pre><code>#include &lt;stddef.h&gt; //NULL

template &lt;typename T&gt;
class Node {
public:
    Node&lt;T&gt;* prev;
    Node&lt;T&gt;* next;
    T value;

    Node(); ~Node();

    void nullify ();

private:
};

template &lt;typename T&gt;
void Node&lt;T&gt;::nullify() {
    this-&gt;value = NULL;
    this-&gt;next = NULL;
    this-&gt;prev = NULL;}
</code></pre>

<p>The last thing I tried was event just returning <code>this-&gt;head-&gt;value</code> without checking the input integer in operator[].</p>

<p>The class is not finished yet, so don't wonder why there are only two functions implemented...</p>

<p><strong>Please feel free to tell me how to write this code better if you find something very bad in it</strong>, I am really bad in this.</p>
