Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago