Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Vector Arithmetic and Vector Drawings [3/10]

Arithmetic operator + can be used instead of the memeber function .add to add points and vectors. However, not all combinations of types are allowed.

Arithmetic operator + can add two vectors, resulting in a new vector. It can not add two points.

Also, operator + can move a point by a vector. In this case, the point must be a left operand of operator + , and the vector must be a right operand. The opposite order is not allowed.

Operator - can be used in the same way as operator +.

Uncomment the commented lines to see the error descriptions.

Loading...