Vector(const Vector& other) // Copy constructor
{
x = other.x;
y = other.y;
Why is the argument a const?
See Question&Answers more detail:os Vector(const Vector& other) // Copy constructor
{
x = other.x;
y = other.y;
Why is the argument a const?
See Question&Answers more detail:osYou've gotten answers that mention ensuring that the ctor can't change what's being copied -- and they're right, putting the const there does have that effect.
More important, however, is that a temporary object cannot bind to a non-const reference. The copy ctor must take a reference to a const object to be able to make copies of temporary objects.