Using the following code fragment for a vector with threedimensions, complete the required methods in each spaceprovided:
// Code fragment
#include<iostream>
#include<cmath>
using namespace std;
class Vec3{
private:
double values[3];
public:
Vec3( double v0, double v1, double v2){
values[0] = v0; values[1] = v1; values[2] = v2;
}
}// End of code fragment
(1.) Define the copy constructor:
(2.) Create a two parameter mutator method:
(3.) Overload the * operator such that when the Vec3 is multipliedby a float it returns a scaled Vec3 object (e.g. Vec3(1,2,3) * 2 ==Vec3(2,4,6)):
Solution
Given below is the completed code fragment according to thespecifications of the question.
// Code fragment
#include<iostream>
#include<cmath>
using namespace std;
class Vec3{
private:
double values[3];
public:
Vec3( double v0, double