The compiler gives me a error C2955: 'Node' : use of class template requires template argument list. Some one wanna look it over and gimme some tips?

//list.h
#ifndef LIST_H
#define LIST_H

#include "node.h"
#include <iostream>

template <typename T>
class List
{
private:
	Node * m_head_node;
	Node * m_current_node;
	Node * m_tail_node;
public:
	List()
	{
		m_head_node = new Node;
		m_head_node->prevPtr = NULL;
		m_current_node = m_head_node;
		m_tail_node = m_head_node;
	}
	void Add(T const &a)
	{
		m_tail_node->nextPtr = new Node;
		m_tail_node->value = a;
		m_tail_node->nextPtr->prevPtr = m_tail_node;
		m_tail_node = m_tail_node->nextPtr;	
	}
	void Display()
	{
		m_current_node = m_head_node;
		while (m_current_node->nextPtr != NULL)
		       std::cout<<m_current_node->value;
	}
};

#endif

//node.h
#ifndef NODE_H
#define NODE_H

template <typename T>
class Node
{
public:
	Node(){};
	Node * prevPtr;
	T value;
	Node * nextPtr;
};

#endif

//main.cpp
#include "list.h"

int main()
{
	List <int> myList;
	myList.Add(5);
	myList.Add(12);
	myList.Add(56);
	myList.Display();

	system("pause");
	return 0;
}

Recommended Answers

All 2 Replies

You problably want to tell Node what it's typename T represents...

class List
{
private:
Node * m_head_node;
Node * m_current_node;
Node * m_tail_node;

maybe make each of these

class List
{
private:
	Node<T> * m_head_node;
	Node<T> * m_current_node;
	Node<T> * m_tail_node;

.... damnit... your right. i cant believe i forgot to do that.
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.