Я только начал практиковать с ++, и я застрял в одной точке.
У меня есть класс Node, и у класса есть конструктор, подобный этому:
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;
}
Пока все работает нормально, но я не могу создать объект Node с NULL parent_node.
Я пробовал это:
Node *n = new Node("state name",NULL,0,15,20,1);
Я также пытался создать новый объект и назначить его в качестве parent_node, но также безуспешно.
Node *temp = new Node();
Node *n = new Node("state name",temp,0,15,20,1);
Я делаю что-то не так с указателем, но я не знаю, что мне не хватает. Я получаю ошибку компиляции, которая говорит, что не соответствует вызов функции.
Заранее спасибо