Question: WRITE IT IN C + + please Now consider the class Point 2 D with the function getDistance that returns the distance of a 2

WRITE IT IN C++ please
Now consider the class Point 2D with the function getDistance that returns the distance of a 2D point from the origin (0,0) :
Note: Accessors and mutators of the member variables are removed in this exercise.
Re-write the definition of the class Point3D (from the previous task) to redefine the function getDistance. The function should return the distance of a 3D point from the origin (0,0,0) according to the following formula:
dis =x2+y2+z22
The following program defines a main function that can be used to test the Point3D class.
The following is a snapshot of the above program's output.
Using object name, the distance of p2 is: 5
Using object name, the distance of p3 is: 3
Using parent pointer, the distance of p3 is: 2.23607
Using child pointer, the distance of p3 is: 3
Note: Even though both pointers are pointing to the same object (p3), the results of the getDistance calls are different because of the static binding.
In the next task, the classes will be using dynamic binding.
WRITE IT IN C + + please Now consider the class

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 Programming Questions!