GIVEN a program point(in c++) with three files(point.h,point.cpp,ma.docx

This preview shows page 1 - 4 out of 7 pages.

GIVEN: a program point(in c++) with three files(point.h,point.cpp,main.cpp) a) point.h /*filename:point.h*/ #include <iostream> using namespace std; class point { private: double xcoord, ycoord;//class attributes public: //default constructor point(); // parameterized constructor point(double x, double y); //overloaded operators double operator -(const point & rhs) const; bool operator ==(const point & rhs) const; // Accessor methods double getX() const { return xcoord; } double getY() const { return ycoord; } //mutators methods void setX(double newX); void setY(double newY); void setXY(double newX, double newY); // print method to cout void point::print(ostream & out)const; };
b) point.cpp /*filename:cpp*/ #include "point.h" #include <iostream> #include <cmath> using namespace std; //default constructor point::point() { cout << "\nconstructing point object, default:\n"; cout << "initializing to zero" << endl; xcoord = 0.0; ycoord = 0.0; } //parameterize constructor point::point(double x, double y) { //input parameters x,y cout << "\nconstructing point object, parameterized:\n"; cout << "input parameters:" << x << "," << y << endl; xcoord = x; ycoord = y; }

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture