/*----------------------------------------------------------------------------------------- Program: Introduce a class Point which represents an ordered pair in 3D. Modify the class to add the following features to the it: TASK I: Define an overloaded operator * which calculates the cross product of two given vectors. } ------------------------------------------------------------------------------------------*/ #include #include using namespace std; class Point { private: double x0, x1, x2 ; public: Point(double a, double b, double c); // syntax of how to declare the point. void print_x0() ; void print_x1() ; void print_x2() ; Point operator + (const Point& ); Point operator * (const Point& ); }; // Here is the constructor for this class. Point::Point(double a, double b, double c) { x0= a; x1= b; x2= c; } void Point::print_x0() { cout << " x-ccordinate of the point = "<< x0 << endl; } void Point ::print_x1() { cout << " y-ccordinate of the point = "<< x1 << endl; } void Point ::print_x2() { cout << " z-ccordinate of the point = "<< x2 << endl; } Point Point::operator + (const Point& input) { Point temp(x0,x1, x2); // x0 and x1 are local to the scope of temp.x0 = temp.x0 + input.x0 ; // X+Y of type point ; X*Y temp.x1 = temp.x1 + input.x1 ; temp.x2 = temp.x2 + input.x2 ; return temp ; } Point Point::operator * (const Point& input ) { Point temp (x0,x1, x2); temp.x0 = temp.x0 * input.x0 ; temp.x1 = temp.x1 * input.x1 ; temp.x2 = temp.x2*input.x2; return temp ; } int main() { Point X(1,2,3); X.print_x0(); X.print_x1(); X.print_x2(); Point Y(-2,3,0) ; Y= X*Y ; /* (3,4).*(4,-3) =(12, -12) Point X's member function '+' that is being used to compute X + input_class i.e. Y. */ Y.print_x0(); Y.print_x1(); Y.print_x2(); return 0; }