I need to turn a linked list class for
ints that I wrote into a class template. I'm having issues with the constructor and
destructor for a struct nested in the List Class, called node.
Layout:
template
class List
{
public:
//Stuff that's not important to this question
private:
struct Node
{
Node(T value); //
constructor
~Node(); // destructor
Node *next; // pointer to the
next Node
T data; // the actual data in the node
static int
nodes_alive; // count of nodes still allocated
};
};
Implementation:
template
typename List::Node::Node(T
value)
{
data = value;
next =
0;
}
template
typename
List::Node::~Node()
{
--nodes_alive;
}
Errors:
Expected ';' at
end of declarationtypename List::Node::Node(T
value)Expected an identifier or
template ID after '::'typename
List::Node::~Node()Expected the class
name after '~' to name a
destructortypename
List::Node::~Node()
Not
really sure what's going on here. My implementation is in a separate file included at
the bottom of the header file. Any help would be greatly appreciated.
No comments:
Post a Comment