Question: Write a C++ console application that demonstrates an inheritance relationship between a class named Point and a class named Point3D. The Point class should have
Write a C++ console application that demonstrates an inheritance relationship between a class named Point and a class named Point3D. The Point class should have data members and accessor methods for the x and y coordinates. It should also have several overloaded methods that will return the distance between 2 points. One overload for the distance method should be a static method that receives 2 Point objects. A 2nd overload should receive 1 Point object and calculate the distance between the current object and the parameter using the this pointer. A 3rd overload should receive a pointer to a Point object. The Point3D class should inherit from the Point class and define an additional data member for the z coordinate along with it's associated accessor method. The Point3D class should overload all 3 distance methods in the base class. These 3 methods will make use of Point3D objects instead of just Point objects. See the following discussion of overloading methods with inheritance: https://stackoverflow.com/questions/14212190/c-issue-with-function-overloading-in-an-inherited-class (Links to an external site.)Links to an external site. Include a 2-arg constructor for the Point class and a 3-arg constructor for it's subclass. Include default constructors for both classes. Demonstrate the classes from main by creating several instances of both and then testing the various distance methods in the classes.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
