Question: Complete the code where it says to add code #include #include // for sqrt() using namespace std; class TwoD { protected: double x, y; //

Complete the code where it says to add code

#include

#include // for sqrt()

using namespace std;

class TwoD

{

protected:

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;}

-=--:----F1 Exercise.cpp Top L1 (C++/l Abbrev)---------------------------

Exercise.cpp has auto save data; consider M-x recover-this-file

File Edit Options Buffers Tools C++ Help

// the TwoD class.

// YOUR CODE GOES HERE

// --->ADD CODE HERE<---:

// Create an inline constructor that initializes the 3D point

// and reuses the TwoD class.

// YOUR CODE GOES HERE

void setZ(double NewZ){z = NewZ;}

double getZ() const {return z;}

// get distance for two 3D points

double getDistance(const ThreeD& point) const;

};

// --->ADD CODE HERE<---:

// Overload the definition of getDistance() of TwoD class so that it

// can calculate the distance between two 3D points

double ThreeD::getDistance(const ThreeD& point) const

{

// YOUR CODE GOES HERE:

}

// --->ADD CODE HERE<---:

// Implement a main() function.

// You should ask the user for the xyz coordinates of two 3D points,

// and then calculate and print out the distance between these two points.

int main()

{

// YOUR CODE GOES HERE

}

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!