std::vector issues

Started by
10 comments, last by EWClay 11 years, 2 months ago

So I fixed my operator=, which fixed the rest. Here's my new function:

Node Node::operator=(Node copy)
{
this->pos.x = copy.pos.x;
this->pos.y = copy.pos.y;
this->parent = copy.parent;
this->g = copy.g;
return *this;
}

Thanks for all the help

Advertisement
It should return a Node reference, to avoid mistakenly modifying a temporary if you use the return value. Also, the parameter should be a const reference to prevent an unnecessary copy.

And I suspect that if you did not define the = operator, the compiler generated one would do the right thing.

This topic is closed to new replies.

Advertisement