Must be C++ programming
The MyPoint class was created to model a point in a
two-dimensional space. The MyPoint class has the properties x and y
that represent x- and y-coordinates, two get functions for x and y,
and the function for returning the distance between two points.
Create a class named ThreeDPoint to model a point in a
three-dimensional space. Let ThreeDPoint be derived from MyPoint
with the following additional features:
A data field named z that represents the z-coordinate.
A no-arg constructor that constructs a point with
coordinates(0,0,0).
A constructor that constructs a point with three specified
coordinates.
A constant get function that returns the z value.
A constant distance(const ThreeDPoint&) function to return the
distance between this point and the other point in the three-dimensional
space.
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.
Here is the answer for your question in C++ Programming Language.
CODE :
#include<iostream> using namespace std; |
SCREENSHOTS :
Please see the screenshots of the code below for the indentations of the code.
OUTPUT :
Any doubts regarding this can be explained with pleasure :)
Get Answers For Free
Most questions answered within 1 hours.