I have a class called node defined in a header file ClassDefinition.h
#ifndef CLASS_DEFINITION_H // if-not-defined
#define CLASS_DEFINITION_H // define
#endif // end-if
#include<vector>
class node{
public:
std::string name;
std::vector<std::string> child_node_vector;
std::vector<int> child_distance_vector;
bool is_visited;
node& operator=(const node &rhs)
{
child_distance_vector = rhs.child_distance_vector;
child_node_vector = rhs.child_node_vector;
is_visited = rhs.is_visited;
name = rhs.name;
return *this;
}
};
In another source code file I have some nodes defined and a vector to hold these nodes Map_Info_Reader.cpp
#include <ClassDefinition.h>
node Eforie;
node Vaslui;
node Iasi;
node Neamt;
std::vector<node> node_list;
node_list[0] = Eforie;
node_list[1] = Vaslui;
node_list[2] = Iasi;
node_list[3] = Neamt;
(other class variables are set further down in file)
Both of these are called from my main source code file DFS_Agent.cpp
#include <Class_Definition.h>
#include <Map_Info_Reader.h>
void Move_To_Node(node){
node current_node = Vaslui;
std::vector<std::string> Search_Queue;
Search_Queue.resize(1);
Search_Queue[0] = "Vaslui"
for (int i = 0; i<node_list.size(); i++)
{
if (Search_Queue[0] == node_list[i].name)
{
current_node = node_list[i];
}
}
} I get a compiler error: no operator "=" matches these operands. Operand types are node = node from line current_node = node_list[i]
node& operator=(const node &rhs)return *this;at the end of the assignment operator. are there any other exceptionsvoid Move_To_Node(node){looks weird for me