error C2244 unable to match function definition to an existing declaration

I’m trying to create a simple template list in C++, Visual Studio 2010 & I’m the getting : error C2244 unable to match function definition to an existing declaration.

I’ve tried to change it to ‘typename’ but it didn’t help.

it’s a basic template list with the very basic functions ( Ctor,Dtor,Add,Delete).

Please help.

#ifndef LIST_H_
#define LIST_H_

template <typename T>
class Node
{
    T* m_data;
    Node* next;
public:
    Node(T*, Node<T>*);
    ~Node();
    void Delete (Node<T>* head);
};

template <typename T>
Node::Node(T* n, Node<T>* head)
{ 
    this->m_data = n;
    this->next=head;
}

template <typename T>
void Node::Delete(Node<T>* head)
{
    while(head)
    {
        delete(head->m_data);
        //head->m_data->~data();
        head=head->next;
    }
}

template <typename T>
class List
{
    Node<T*> head;
public:
    List();
    ~List();
    void addInHead (T*);
};

template <typename T>
void List :: addInHead (T* dat)
{
    head = new Node<T*> (dat,head);
}

template <typename T>
List::List()
{
    head = NULL;
}

template <typename T>
List :: ~List()
{
    head->Delete(head);
}

  #endif

You have the code above.

Leave a Comment