|
发表于 2009-10-31 01:01:35
|
显示全部楼层
IP:江苏扬州
.....好多错误
#include <iostream> using std::cout; using std::endl; class Point{ float x,y; public: Point(float a=0,float b=0) { x=a; y=b; } void SetP(float a=0,float b=0){x=a,y=b;} void Display(){cout<<"位置是:("<<x<<","<<y<<")\n";} }; class Circle:public Point{ float r; public: Circle(float z=1,float x=0,float y=0){r=z;} void SetC(float z=1,float x=0,float y=0){r=z;SetP(x,y);} void Print() { cout<<"圆的"; Display(); cout<<"圆的半径是:"<<r<<endl; } }; void main() { Circle a(3,2); a.Print(); a.SetC(6,8,2); a.Print(); } |
|