2. (20 scores)

2. (20 scores)#

A vector \(\overrightarrow{v}\) on a two-dimensional plane can be expressed as \((a, b)\). The basic operation of a vector is defined as follows:

  1. Vector modulus: \(||\overrightarrow{v}|| = \sqrt{a^2 + b^2}\).

  2. Vector inner product: \(\overrightarrow{v_1} * \overrightarrow{v_2} = a_1 * a_2 + b_1 * b_2\), where \(\overrightarrow{v_1} = (a_1, b_1)\), \(\overrightarrow{v_2} = (a_2, b_2)\).

  3. Cosine distance of vector: \(cos\theta = \frac{\overrightarrow{v_1} * \overrightarrow{v_2}}{||\overrightarrow{v_1}|| * ||\overrightarrow{v_2}||}\), where \(\overrightarrow{v_1} = (a_1, b_1)\), \(\overrightarrow{v_2} = (a_2, b_2)\). If cosine distance is 0, the two vectors are perpendicular; if cosine distance is 1, the two vectors are similar.

Write the program to encapsulate the vector class CVector, and verify the correctness of the CVector.