I have the following structure:
struct PATH {
vector<ARCO_TEMPO> rota;
set<int> rotaAux;
float COST;
int nArcosVoyage;
vector<bool> VisitedNodes;
vector<vector<bool>> VisitedVertices;
int head_no;
int head_time;
int tail_no;
int tail_time;
float reducedCost;
float duracao;
int auxNumAircrafts;
};
How do I create operator = for this structure? I thought I could do it like this:
PATH& PATH::operator=(const PATH& p1) {
COST = p1.COST - cFixo[aa]*p1.auxNumAircrafts;
reducedCost = p1.reducedCost - cFixo[aa]*p1.auxNumAircrafts;
auxNumAircrafts = p1.auxNumAircrafts;
nArcosVoyage = p1.nArcosVoyage;
head_no = p1.head_no;
head_time = p1.head_time;
tail_no = p1.tail_no;
tail_time = p1.tail_time;
duracao = p1.duracao;
for (int i = 0; i < p1.rota.size(); i++) {
rota[i].a.i = p1.rota[i].a.i;
rota[i].a.j = p1.rota[i].a.j;
rota[i].slotTimeU = p1.rota[i].slotTimeU;
rota[i].slotTimeV = p1.rota[i].slotTimeV;
}
for (int i = 0; i < n; i++) {
VisitedNodes[i] = p1.VisitedNodes[i];
}
for (int i = 0; i < n; i++) {
for (int j = 1; j <= max_slot; j++) {
VisitedVertices[i][j] = p1.VisitedVertices[i][j];
}
}
rotaAux = p1.rotaAux;
return *this;
};
However, the following error appears:
error: definition of implicitly-declared 'PATH & PATH :: operator = (const PATH &) 'PATH & PATH :: operator = (const PATH & p1);
How can I fix this?