//See int main() for exercise description. #include #include using namespace std; //--------- class Point //--------- { private: double x, y; public: Point() {} double Distance() const { return sqrt(x*x+y*y); } double GetX() const {return x;} double GetY() const {return y;} void SetY(const double ypar) { y = ypar; } void SetX(const double xpar) { x = xpar; } }; //Overloading << so that cout << PointInstance will work ostream& operator<<(ostream& o, const Point a) //-------------------------------------------- { const int oldWidth = o.width(15); o << "x = " << a.GetX() << "\t"; o << "y = " << a.GetY() << "\t"; o << "d1 = " << a.Distance(); o.width(oldWidth); return o; } int main() { //Create an array of Point-objects and ask values for them. //Print the elements in the array. Note that you can use syntax //cout << PointObject; to 'print' objects of class Point. //Use qsort-function to sort the array in respect to distances. //The lecture material might not give enough //hints, so you may need to use other sources to find out how to use it. //Print the array elements again to see the effect. //-------------------------------------------------------------- return 0; }