Somebody please help me as I can't understand why the compiler is throwing me an error that members x and y are inaccessible even though I have given the friend function declaration?
#include<iostream>
using namespace std;
#include<math.h>
class die;
class point{
int x , y;
public:
friend int die :: dist(point, point);
point(int a,int b){
x=a;
y=b;
}
void display(){
cout<<"the point are ("<<x<<" , "<<y<<")"<<endl;
}
};
class die{
public:
int dist(point p1 , point p2 ){
int final;
final= sqrt((pow((p1.x-p2.x),2))+pow((p1.y-p2.y),2));
return final;
}
};
int main(){
point d(3,4);
d.display();
point e(3,4);
e.display();
die sum;
sum.dist(d,e);
return 0;
}