Home:ALL Converter>error C2244 unable to match function definition to an existing declaration

error C2244 unable to match function definition to an existing declaration

Ask Time:2013-01-26T19:05:05         Author:user2013420

Json Formatter

I'm trying to create a simple template list in C++ with Visual Studio 2010 and I'm the getting:

error C2244 unable to match function definition to an existing declaration

I've tried to change it to typename T but it didn't help.

It's a basic template list with 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

Author:user2013420,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/14536322/error-c2244-unable-to-match-function-definition-to-an-existing-declaration
yy