Question: Need .cpp and .h This is a simple Point class interface file whose objects represent points in the cartesian plane #include using namespace std; class

Need .cpp and .h

This is a simple Point class interface file whose objects represent points in the cartesian plane

#include

using namespace std;

class Point

{

public:

Point(); // default constructor

Point(double x, double y); // another constructor

double x() const; // get function, return _x

double y() const; // get function, return _y

private:

double _x, _y;

};

Here is a test driver file for the Point class (do not modify the driver file):

#include "Point.h" // defines Point class

#include

using namespace std;

int main()

{

Point p0; // invokes default constructor

Point p1(5, -2); // invokes constructor

Point p2 = p1;

p0 = p1; // invokes assignment operator

cout << "p0.x() = " << p0.x() << " ";

cout << "p0.y() = " << p0.y() << " ";

}

  1. Write the implementation file of Point class.

  1. Add the following member functions to the point class, implement them, and test them in the driver:

  1. Returns polar coordinate r = x2+y2

double magnitude() const;

  1. Move the point dx in x direc and dy in y direction

void move(double dx, double dy);

  1. Print the point in the format (x, y) to ostream out

void print(ostream & out) const;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!