Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

The type vector2D [2/11]

Every vector has coordinate components. Two-dimensional vectors have two coordinate components commonly named x and y.

The type vector2D has two members named .x and .y that represent the vector's coordinate components. Those two members are both getters and setters.

The getter .len from type vector2D returns the length of a vector. This member is not a setter, meaning that a new length cannot be directly assigned to the vector.

The initializer for type vector2D accepts two values that specify the coordinate components x and y.

Uncomment the erroneous lines to see the error description.

Loading...