Question: please help with this . Bellow is the starting code to work with: #include #include // for sqrt() using namespace std; class TwoD { private:
please help with this .


Bellow is the starting code to work with:
#include
class TwoD { private: double x, y; // x and y coordinates public: // inline implementation of constructor TwoD(){x = y = 0.0;} // default constructor TwoD(double i, double j):x(i), y(j){} // inline implementation of member functions void setX(double newX){x = newX;} void setY(double newY){y = newY;} double getX() const {return x;} double getY() const {return y;} // get distance of 2D points double getDistance (const TwoD& theSecondPoint) const; };
// calculate the distance of two 2D points double TwoD::getDistance(const TwoD& theSecondPoint) const { double point1[2]; double point2[2]; double dx, dy; double distance;
point1[0] = x; point1[1] = y;
point2[0] = theSecondPoint.getX(); point2[1] = theSecondPoint.getY();
dx = point2[0] - point1[0]; dy = point2[1] - point1[1];
distance = sqrt(dx * dx + dy * dy); return distance; }
class ThreeD:public TwoD { private: double z; public:
// --->ADD CODE HERE
// --->ADD CODE HERE
void setZ(double newZ){z = newZ;} double getZ() const {return z;}
// get distance for two 3D points double getDistance(const ThreeD& theSecondPoint) const; };
// --->ADD CODE HERE
// --->ADD CODE HERE Start with the repl code provided to you. Finish the program so that it compiles and runs. The instructions are contained in the C++ file. Your completed program should generate output similar to the following: TwoD default constructor This program asks for the coordinates of two points in 3D space and calculates their distance, Please enter the xyz coordinates for the first point: 111 Please enter the xyz coordinates for the second point: 2 3 4 TwoD constructor with two arguments Distance is: 3.74166 The following refreshes your memory on how to calculate the distance between two points in 3D place. Suppose we have the following two points in a 3D space: y point1(x1.y1.21) Z point2(x2.72.22) The distance between point1 and point2 is: dis = (x,- x;)* +(y, - y)' +(2,-2) More details: In main: 1. Create one ThreeD object using the default constructor. Use the setters to set x, y, and z. 2. Create the second ThreeD object using the constructor with three arguments. in the TwoD class: 1. Add a cout statement to the TwoD default constructor with a message "TwoD default constructor" 2. Add a cout statement to other TwoD constructor with a message "TwoD constructor with two arguments
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
