C++中点线圆的类定义及继承.docVIP

  • 8
  • 0
  • 约4.24万字
  • 约 6页
  • 2017-06-08 发布于河南
  • 举报
C中点线圆的类定义及继承

/*#includeiostream #includecmath using namespace std; class Point { private: float x,y; public: Point(){} Point(float a,float b):x(a),y(b){} Point(Point a); float Distance(Point b); }; Point::Point(Point a) { x=a.x; y=a.y; } float Point::Distance(Point b) { return sqrt((x-b.x)*(x-b.x)+(y-b.y)*(y-b.y)); } class Line:public Point { private: Point a,b; public: Line(float x1,float y1,float x2,float y2):a(x1,y1),b(x2,y2){} float Display(); }; float Line::Display() { return a.Distance(b); } int main() { Point a; Point b(7.8,9.8),c(34.5,67.8); a=c; cout两点之间距离是:a.Distance(b)endl

文档评论(0)

1亿VIP精品文档

相关文档