Hi all, I have just started to practice c++ and I am stuck at one point. I have a Node class and the class has a constructor like this:
class Node
{
public:
Node(std::string,Node *,int,int,int,int);
private:
std::string state;
Node* parent_node;
int total_cost;
int path_cost;
int heuristic_cost;
int depth;
}
Node::Node(std::string state,Node *parent_node,int path_cost,int heuristic_cost,int total_cost,int depth)
{
this->state=state;
this->parent_node=parent_node;
this->path_cost=path_cost;
this->heuristic_cost=heuristic_cost;
this->total_cost=total_cost;
this->depth=depth;
}
Everything works ok so far, but I can not create a Node object with a NULL parent_node. I have tried this:
Node *n = new Node("state name",NULL,0,15,20,1);
I have also tried creating a new object and assigning it as parent_node, but no success either.
Node *temp = new Node();
Node *n = new Node("state name",temp,0,15,20,1);
I am doing something wrong with the pointer but I don't know what I am missing. I get a compile error which says no matching function call.
Thanks in advance