Hey I have written a code using C++. The program is about calculating distance between two points of a plane. Without using class the program works fine but whenever I do it with class & wanna return a value it doesn't return any value.
`
#include<iostream>
#include<math.h>
using namespace std;
class plane{
public:
void getdata(float X1,float X2,float Y1,float Y2)
{
cout<< "Enter point X1 ";
cin>>X1;
cout<< "Enter point Y1 ";
cin>>Y1;
cout<< "Enter point X2 ";
cin>>X2;
cout<< "Enter point Y2 ";
cin>>Y2;
}
double distance2(float A1,float A2,float B1,float B2)
{
double distance;
float side1,side2;
side1=(A1-A2)*(A1-A2);
side2=(B1-B2)*(B1-B2);
distance=sqrt(side1+side2);
return distance;
}
};
int main()
{
float X1,X2,Y1,Y2;
plane plane1,plane2;
plane1.getdata(X1,X2,Y1,Y2);
plane1.distance2(X1,X2,Y1,Y2);
cout<<endl;
plane2.getdata(X1,X2,Y1,Y2);
plane2.distance2(X1,X2,Y1,Y2);
}