Notes on myVector2


Vector2 has now been extended to include two new operators, - (vector subtraction) and * (multiplication of a vector by a scalar) and a function to form a dot product. This new class, myVector2, also has functions which permit the values of individual elements to be read (not written).
The new class inherited the addition operator of the parent class Vector2. It did not have to be implemented again. The output operator << works for the derived class too.
We have not thrown away any of the work we did in implementing Vector2 and we did not have to modify Vector2. Everything has been reused. C++ is an ecologically sound language.
An obvious operator was not available for vector dot product so a function was used.
Using inheritance to overcome deficiencies of a base class is not really what it's intended for. The base class should have been better designed in the first place.