You are on page 1of 2

Ehtasham Ali

BSE153003

Lab 9 Home task 2


#include<iostream>
using namespace std;
class Planepoint {
protected:
int X;
int Y;
public:
Planepoint() :X(0), Y(0){}
void getX(int x){
X = x;
}
void getY(int y) {
Y = y;
}
int planedistance() {
X =sqrt( (X*X) + (Y*Y));
cout << "Distance of plane is " << X << endl;
return X;
}
};
class Spacepoint : public Planepoint {
private:
int Z;
public:
Spacepoint() : Planepoint() {
X=0; Y=0; Z=0;
}
Spacepoint(int x, int y, int z) : Planepoint (x, y, z) {
Z = z;
}
void spacedistance() {
Z=sqrt((X*X) + (Y*Y)+(Z*Z));
}
int getZ() {
cout << "Distance in space is " << Z << endl;
return Z;
}

};
void main() {
int x;
int y;
int z;
cout << "Enter the value of x" << endl;
cin >> x;
cout << "Enter the value of y" << endl;
cin >> y;
Planepoint P;
P.getX(x);
P.getY(y);
P.planedistance();
cout << "Enter the value of z" << endl;
cin >> z;
Spacepoint S(x, y, z);
system("pause");
}

You might also like