Dear all,
I am completely lost and I don't see at all my mistake! I thought this would be a very easy step in the building of my classes.
Thanks a lot for your help!
In the context of graph theory, I have a class Node. As attribute of this class, there is a set (called neighbours) of pointers to Node objects. When I try to compile, I get the following error.
I also have a public function addNode(*Node) which add a node pointer in the neighbours set.
Graph.hpp
class Node {
public:
Node(string); // constructor (specify only the name);
Node(string, string); // constructor (specify the name and the color);
// blabla
void addNeighbour(Node*); // add a neighbour in the set of neighbours
// blabla
private:
string color; // node color
string name; // node name
set<*Node> neighbours; // set of pointers to neighbours nodes
};
code of the function addNeighbours (in Node.cpp)
void Node::addNeighbour (Node* neighbour) {
neighbours.insert(neighbour);
}
The error message is the following one.
In file included from Graph.cpp:10:
Node.hpp:36: error: ‘*’ cannot appear in a constant-expression
Node.hpp:36: error: template argument 1 is invalid
Node.hpp:36: error: template argument 2 is invalid
Node.hpp:36: error: template argument 3 is invalid
Thanks again!