My problem is that I'm trying to declare the object Node ,declare a vector of objects Nodes and check that vector with a method of the same class, my complier(visual studio 2019) gives me "Error: Unable to open file main.obj. Error code = 0x80070002".
any suggestions to make it work as I described ?
here is my code :
class Node {
public:
int Node_x, Node_y;
Node(int x,int y){
Node_x = x;
Node_y = y;
}
bool is_Checked(Node point(int x, int y));
};
vector <Node> visited_Nodes;
vector <Node> wall_Nodes;
std::vector<Node>::iterator it = visited_Nodes.begin();
bool Node::is_Checked(Node point(int x,int y)) {
it = std::find(visited_Nodes.begin(), visited_Nodes.end(), point(Node_x, Node_y));
if (it != visited_Nodes.end()) {
return true;
}
else {
visited_Nodes.push_back(point(Node_x, Node_y));
return false;
}
}
So basically I find out that I can't use find function to find an object in vector of objects (correct me if I'm wrong) so I used elements of the objects (which are unique)
class Node {
public:
int Node_x, Node_y;
Node(int x,int y){
Node_x = x;
Node_y = y;
}
bool is_Checked(Node point(int x,int y));
};
vector <int> visited_Nodes_x;
vector <int> visited_Nodes_y;
//vector <Node> wall_Nodes;
std::vector<int>::iterator it_x = visited_Nodes_x.begin();
std::vector<int>::iterator it_y = visited_Nodes_x.begin();
bool Node::is_Checked(Node point(int x,int y)) {
it_x = find(visited_Nodes_x.begin(), visited_Nodes_x.end(), point(Node_x,Node_y).Node_x);
it_y = find(visited_Nodes_y.begin(), visited_Nodes_y.end(), point(Node_x,Node_y).Node_y);
if (visited_Nodes_x.empty() || it_x == visited_Nodes_x.end()) {
visited_Nodes_x.push_back(point(Node_x,Node_y).Node_x);
return false;
}
else {
return true;
}
}
User contributions licensed under CC BY-SA 3.0