I am implementing a Node class in C++ as an assignment.
The class :
#pragma once
#include <iostream>
class Node {
size_t id;
std::pair<size_t, Node> dist;
public:
//Node();
//Node(const size_t);
Node(const size_t, const std::pair<size_t, Node>);
Node(const Node&);
//std::pair<const bool, const std::string> setId(size_t);
//std::pair<const bool, const std::string> setDist(std::pair<size_t, Node>);
//void operator=(const Node&);
};
Node::Node(const size_t nodeId, const std::pair<size_t, Node> distanceFromPreviousNode) : id(nodeId), dist(distanceFromPreviousNode) { }
Node::Node(const Node& node) {
try {
id = node.id;
dist = node.dist;
throw std::string("Could not set the id and distance to given value");
}
catch (std::string exception) {
std::cerr << exception;
exit(1);
}
}
I assure that all the functions have been implemented in the node.cpp
file.
However, I'm getting the following error
std::pair<size_t, Node>::second uses undefined class 'Node'
I am completely clueless as to what the error wants me to do and why the intellisense
is not detecting it.
Oh, also the ctor
is generating it (at least, that's the line number the error message points to)