A class named MyPoint represents a point with x and y-coordinates.
The class contains:
* Two data fields x and y the represent the coordinates,
* A no-argument constructor that creates a point (0, 0),
* A constructor that constructs a point with specified coordinates,
* Two get functions for data fields x and y, respectively,
* A function named distance that returns the distance from this point
to another point of the MyPoint type. For given the two points (x1, y1) and (x2, y2),
the distance between these points is given by the formula:
v( x2-x1)2+ (y2-y1)2
Create a class named ThreeDPoint to model a point in a three-dimensional space.
Let the ThreeDPoint be derived from MyPoint with the following features:
A data field named z that represents the z-coordinate,
A no-argument constructor that constructs a point with coordinates (0, 0 ,0),
A get function that returns the z value,
Override of the distance function to return the distance between two points in
the three-dimensional space.
Draw the UML diagram for the classes involved. Implement the classes.
Write a test program that creates two points (0, 0, 0) and (10, 30, 25.5)
and displays the distance between them.
A class named MyPoint represents a point with x and y-coordinates
- Technology: CPP-Programming
- Code: SHC_CPP_10002