Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

The type vector2D [6/11]

A point can be 'moved' by a vector. The getter function .add from type point2D accepts an argument of type vector2D.

The result of adding a vector to a point is a new point. The position of the new point is what one would get if the original point was moved by the given vector.

Getter functions always produce a new value, they cannot change the original value, therefore the variable p in this program is not modified by the getter add.

While a vector can be added to a point, it is not allowed to add two points, because such operation makes no sense.

Loading...