Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the Code: #include #include using namespace std; struct point { int x, y; }; void setX(point & p, double xV); void setY(point & p,

Complete the Code:

#include

#include

using namespace std;

struct point {

int x, y;

};

void setX(point & p, double xV);

void setY(point & p, double yV);

double getX(const point & p);

double getY(const point & p);

void print(ostream & w, const point & p);

point makePoint(double xV, double yV);

point * makePointPtr(double xV, double yV);

void makePoint(double xV, double yV, point & result);

void makePoint(double xV, double yV, point * ptrAns);

void input(point & p);

double Distance(const point & p1, const point & p2);

void main() {

point P1, P2;

// test setX and setY for P1 and P2

// for P1 and P2, print out the x and y value for each one of them using the getX and getY methods

// print out the x and y value for P1 or P2 using print method

point Pa;

// assign x and y values of Pa using the first makePoint method

point * Pb;

// assign x and y values of Pb using the makePointPtr method

point Pc;

// assign x and y values of Pc using the second makePoint method, notice that Pc is passed as ref

point Pd;

// assign x and y values of Pd using the third makePoint method, notice that Pd is passed as pointer

point P3;

// assign P3 x and y values using the input method

// create a double data type variable and assign the value returned from the distance method to it using P1 and P2

system("pause");

}

void setX(point & p, double xV) {

}

void setY(point & p, double yV) {

}

double getX(const point & p) {

}

double getY(const point & p) {

}

void print(ostream & w, const point & p) {

}

point makePoint(double xV, double yV) {

}

point * makePointPtr(double xV, double yV) {

}

void makePoint(double xV, double yV, point & result) {

}

void makePoint(double xV, double yV, point * ptrAns) {

}

void input(point & p) {

}

double Distance(const point & p1, const point & p2) {

double dis;

dis = sqrt(pow((p1.x - p2.x), 2) + pow((p1.y - p2.y), 2));

return dis;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions