Hi, i'm trying to implement a node class to be used with a linked list. When try to complile i get the following errors in the .cpp file:
Node.cpp:26: error: syntax error before `::' token
Node.cpp:31: error: syntax error before `*' token
Node.cpp:36: error: syntax error before `*' token
Everything appears to be ok, but obviously it isn't. Any help would be much appreciated.
My Node.h file:
namespace oneill_node1
{
class node
{
public:
typedef int value_type;
node(const value_type& initial_data = value_type(), node* initial_link = NULL);
void set_data(const value_type& new_data);
void set_link(node* new_link);
value_type get_data() const;
const node* get_link() const;
node* get_link();
private:
value_type data;
node* link;
};
}
My Node.cpp file:
#include "Node.h"
namespace oneill_node1
{
node::node(const value_type& initial_data, node* initial_link)
{
data = initial_data;
link = initial_link;
}
void node::set_data(const value_type& new_data)
{
data = new_data;
}
void node::set_link(node* new_link)
{
link = new_link;
}
value_type node::get_data() const //line 26
{
return data;
}
const node* node::get_link() const //line 31
{
return link;
}
node* node::get_link() //line 36
{
return link;
}
}