#include <iostream>
using namespace std;
class Time
{
public:
Time(double xx,double yy):x(xx),y(yy){}
double getx(){return x;}
double gety(){return y;}
void aaa1(Time &t);
friend void aaa2(Time &t1,Time &t2);
private:
double x;
double y;
};
void Time::aaa1(Time &t)
{
cout<<"("<<(x+t.x)/2<<","<<(y+t.y)/2<<")"<<endl;
}
void aaa2(Time &t1,Time &t2)//友元函数不有“Time::”
{
cout<<"("<<(t1.x+t2.x)/2<<","<<(t1.y+t2.y)/2<<")"<<endl;
}
void aaa3(Time &t1,Time &t2)
{
cout<<"("<<(t1.getx()+t2.getx())/2<<","<<(t1.gety()+t2.gety())/2<<")"<<endl;
}
int main()
{
Time b1(1.5,2.6),b2(5.2 ,6.4);
b1.aaa1(b2);//成员函数直接访问私有数据
aaa2(b1,b2);//友元函数也可以直接访问私有函数
aaa3(b1,b2);//普通函数只能通过外部接口
return 0;
}