/*----------------------------------------------------------------------------------------- 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; template class Point { private: double x0, x1, x2 ; // double *x; // *x=*(x+0)=x0 ; *(x+1)=x1 ; *(x+ 2 ) =x2 ; double x[3]; public: Point(); // syntax of how to declare the point. void print_x0() ; void print_x1() ; void print_x2() ; double L2_norm() ; }; // Here is the constructor for this class. template Point::Point() { cout << "Please enter the " << dim << " coordinates for the Point: " << endl; for (unsigned int i = 0 ; i < dim ; ++i) { cout << "Please input the "<< i << " th coordinate for the Point: " ; cin >> x[i] ; //++x; cout < void Point::print_x0() { cout << " x-ccordinate of the point = "<< x0 << endl; } template void Point::print_x1() { cout << " y-ccordinate of the point = "<< x1 << endl; } template void Point ::print_x2() { cout << " z-ccordinate of the point = "<< x2 << endl; } template double Point::L2_norm() { double return_value = 0 ; for (unsigned int i = 0 ; i < dim ;++i) return_value +=x[i]*x[i]; return sqrt(return_value) ; } int main() { Point<2> X ; //TODO: decide how to initialize the class and the coordinates. cout << " The L2 norm for X is: "<< X.L2_norm() << endl; return 0; }