This exercise is available at https://study.find-santa.eu/exercises/cpp/operator_overloading/.
For the sake of the environment, please avoid printing these instructions in the future. Thank you!

Operator Overloading

  1. Implement vector arithmetics
    Libraries for numeric computations allow calculations with arrays. One such library is numpy. It is your task to allow C++ std::vector to be used for calculation following roughly the same API as numpy's arrays.
    1. Overload the + operator (operator+) for vectors of the same type to represent the following behavior. The resulting new vector must contain the sum of each element whenever the element's index exists in both vectors. If one vector has more elements than the other, the additional elements should be taken without modification. For example:
      // v1: 1, 2, 3
      // v2: 7, 8
      v3 = v1 + v2;  // v3: 8, 10, 3 (1+7, 2+8, 3)
    2. Overload the - operator (operator-) in a similar way to the + operator.
    3. Overload the * operator (operator*) for vectors of the same type to represent the following behavior. The resulting vector must contain the product of each element whenever the element's index exists in both vectors. If one vector has more elements than the other, display an error message and exit the program. For example:
      // v1: 1, 2, 3
      // v2: 7, 8, 9
      v3 = v1 * v2;  // v3: 7, 16, 27 (1*7, 2*8, 3*9)
    4. Overload the * operator (operator*) for multiplying a vector with a scalar of the same type as the vector. It must be possible to write scalar * vector as well as vector * scalar. Return a new vector that has each element of the given vector multiplied by the scalar. For example:
      // v1: 1, 2, 3
      // scalar: 3
      v2 = v1 * 3;  // v2: 3, 6, 9 (1*3, 2*3, 3*3)
      v3 = 5 * v1;  // v3: 5, 10, 15
    Name the program file: operator_overloading.cpp