Problems in Writing the Node class for a generic LinkedList

I am trying to write a generic LinkedList class. I want my node class to have the <<, >>, >, <, >=, <= to make the sort function cleaner when I start to implement it in the LinkedList class. However i'm having a couple of problems. I've written the code below along with the errors I get.

Node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef NODE_H
#define NODE_H

#include <ostream>

template<typename Kind>

class Node
{
public:
    Node();
    Node(const Kind&);
    Node(const Node&);

    Node& operator = (const Node&);

    friend std::ostream& operator << (std::ostream&, const Node& );
    friend std::ostream& operator >> (std::istream&, Node& );

    friend bool operator > (const Node&, const Node&);
    friend bool operator < (const Node&, const Node&);

    friend bool operator >= (const Node&, const Node&);
    friend bool operator <= (const Node&, const Node&);

    friend bool operator == (const Node&, const Node&);
    friend bool operator != (const Node&, const Node&);

    Kind    ListItem;
    Node*   NextItem;
};

#endif // NODE_H 


Node.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "Node.h"
#include <ostream>

template <typename Kind>
Node<Kind>::Node()
{
    this->NextItem=NULL;
}

template <typename Kind>
Node<Kind>::Node(const Kind & item)
{
    this->ListItem = item;
    this->ListItem = NULL;
}

template <typename Kind>
Node<Kind>::Node(const Node & node)
{
    this->ListItem = node.ListItem;
    this->NextItem = node.NextItem;
}

template <typename Kind>
Node& Node<Kind>::operator = (const Node& node)
//error: expected constructor, destructor, or type conversion before '&' token
{
    this->ListItem = node.ListItem;
    this->NextItem = node.NextItem;
    return (*this);
}


template<typename Kind>
std::ostream& operator << (std::ostream& Console, const Node& node)
/*1.error: ISO C++ forbids declaration of 'Node' with no type
* 2.error: expected ',' or '...' before '&' token
*/
{
    return (Console << node.ListItem);// error: 'node' was not declared in this scope
}


Thanks for your help!
Topic archived. No new replies allowed.