Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
Object comparison?
So in this code, I have a vector(nodes) containing the nodes for each grid. When you delete a node, it needs to remove it from the vector. But I'm having trouble with the comparison. I need it to compare the node given via function arg and the node at nodes[i], and if they're the same, remove it. How can I make this work? https://code.sololearn.com/cIVz1q45no78/?ref=app
1 Answer
+ 7
you can overload the relational operator; it should be simple in your case.
bool operator==(const node &n) const{
return (row == n.row && column == n.column);
}
You can put that directly in the node structure ;)