Question: C + + pls; the MyPoint class was created to model a point in a two - dimensional space. The MyPoint class has the properties
C pls;
the MyPoint class was created to model a point in a twodimensional space. The MyPoint class has the properties x and y that represent x and ycoordinates, two get functions for x and y and the function for returning the distance between two points. Create a class named ThreeDPoint to model a point in a threedimensional space. Let ThreeDPoint be derived from MyPoint with the following additional features:
A data field named z that represents the zcoordinate.
A noarg constructor that constructs a point with coordinates
A constructor that constructs a point with three specified coordinates.
A constant get function that returns the z value.
A constant distanceconst MyPoint& function to return the distance between this point and the other point in the threedimensional space.
Implement the classes. Write a test program that creates two points and and displays the distance between them.
When you create a new submission, you'll notice a template code. Your task is to fill in the missing code parts indicated by "your code here".
#include
#include
using namespace std;
class MyPoint
private:
double x;
double y;
public:
MyPoint
x y ;
MyPointdouble x double y
thisx x;
thisy y;
double distanceconst MyPoint& p const
return sqrtx pxx pxy pyy py;
double getX const
return x;
double getY const
return y;
;
class ThreeDPoint: public MyPoint
private:
double z;
public:
ThreeDPoint;
ThreeDPointdouble x double y double z;
double getZ const;
double distanceconst ThreeDPoint& p;
;
Write your code here to implement the constructors and functions in ThreePoint
int main
Write your code here in the main function
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
