#include <iostream>
#include <cmath>
using namespace Std;
Class MyPoint
{
Private
Double x, y;
Public
The No-arg constructor that contruccts a point with coordinates (0,0)
MyPoint ();
MyPoint (double x, double y);
Double GetX () const;
Double GetY () const;
Display the distance between and points in two-dimensional space.
Double distance (const mypoint &point);
};
Mypoint::mypoint () {
x=0.0;
y=0.0;
}
Mypoint::mypoint (double x,double y) {
this->x = x;
This->y = y;
}
Double Mypoint::getx () const{
return x;
}
Double mypoint::gety () const{
return y;
}
Double mypoint::d istance (const mypoint &point) {
Double a=this->x-point.x;
Double b=this->y-point.y;
return sqrt (POW (a,2) + POW (b,2));
}
Class Threedpoint:public MyPoint
{
Private
Double Z;
Public
The No-arg constructor that contruccts a point with coordinates (0,0,0)
Threedpoint ();
Threedpoint (double x, double y, double z);
Double GetZ () const;
Display the distance between and points in three-dimensional space.
Double distance (const threedpoint &point);
};
Threedpoint::threedpoint (): MyPoint () {
z=0.0;
}
Threedpoint::threedpoint (double xx,double yy,double z): MyPoint (xx,yy) {
This->z = Z;
}
Double Threedpoint::getz () const{
return z;
}
Double threedpoint::d istance (const threedpoint &point) {
Double A = This->getx ()-point.getx ();
Double b = this->gety ()-point.gety ();
Double C = this->z-point.z;
return sqrt (POW (a,2) + POW (b,2) + POW (c,2));
}
int main () {
return 0;
}
1001. Extending MyPoint Class