题目内容
阅读程序,写出运行结果#include#includeclass point;//前向声明point类class A{public:double distance(point &p1,point &p2);//...};class point{private:double x,y;public:point(double xx=0,double yy=0) {x=xx;y=yy;}double get_x( ) {return x;}double get_y( ) {return y;}friend double A::distance(point &p1,point &p2); //A类的成员函数作point的友元};double A::distance(point &p1,point &p2){return (sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)));}void main( ){point myp1(1,1),myp2(4,5);A obj;//必须声明一个A类的对象cout<<"Thedistance is:"<
查看答案
搜索结果不匹配?点我反馈