求问题解释,请高手帮忙!!!
#include<iostream.h>class point
{
public:
point(double x1=0,double y1=0)
{
x=x1;
y=y1;
}
double display()
{
cout<<"("<<x<<","<<y<<")";
return 0;
}
double getx()
{
return x;
}
double gety()
{
return y;
}
private:
double x,y;
};
class line
{
public:
line(point &pp1,point &pp2):p1(pp1),p2(pp2)
{
k=(p1.gety()-p2.gety())/(p1.getx()-p2.getx());
}
void display()
{
cout<<"该直线斜率是:";
cout<<"k="<<k<<endl;
cout<<"直线上的两点坐标分别是:";
p1.display();
cout<<",";
p2.display();
cout<<endl;
}
private:
point p1,p2;
double k;
};
void main()
{
double a,b,c,d;
cout<<"输出该直线上的两点:"<<endl;
cout<<"输入第一点坐标:";
cin>>a>>b;
cout<<"输入第二点坐标:";
cin>>c>>d;
point q1(a,b);
point q2(c,d);
line L1(q1,q2);
L1.display();
}
line(point &pp1,point &pp2):p1(pp1),p2(pp2) //这句是什么意思。。。。??是联系两个类的ma ?
类与类之间还有什么方式可以联系起来??