#include<iostream>
#include<math.h>
using namespace std;
class Point
{
private:
double x;
double y;
public:
Point(double a,double b)
{
x = a;
y = b;
}
int GetPoint()
{
cout<<"("<<x<<","<<y<<")";
return 0;
}
int distancetoLine()
{
}
friend class Tool;
};
class Tool
{
public:
double GetX(Point &A)
{
cout<<A.x<<endl;
return A.x;
}
double GetY(Point &A)
{
cout<<A.y<<endl;
return A.y;
}
double dis(Point &A)
{
cout<<sqrt(A.x*A.x+A.y*A.y)<<endl;
return sqrt(A.x*A.x+A.y*A.y);
}
};
int main()
{
Point A(2.0,3.0);
Tool T;
T.GetX(A);
T.GetY(A);
T.dis(A);
return 0;
}
友元类的使用
最新推荐文章于 2022-10-31 12:24:45 发布