问答题

请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2。其中在编辑窗口内显示的主程序文件中定义有类Point和Circle,以及主函数mmn。程序文本中位于每行“//****found****”之后的一行内有一处或多处下画线,请在下画线处填写合适的内容,并删除下画线。经修改后运行程序,得到的输出结果应为: Point:(0,0)3 Point:(4,5)6 28.2743 113.097 #include <iostream> using namespace std; class Point //定义坐标点类 { public: Point (int xx =0, int yy=0) {x=xx; y=yy;} void PrintP () {cout << "Point: (" <<x <<"," <<y<<")";} private: int x,y; //点的横坐标和纵坐标 }; class Circle //定义圆形类 { public: Circle():rr (0) {} //无参构造函数 Circle (Point& cen, double tad =0); //带参构造函数声明 double Area () {return rr* rr* 3.14159;} //返回圆形的面积 //PrintP函数定义,要求输出圆心坐标和半径 //************* ound************** void PrintP () {______; cout <<rr <<endl;} private: Point cc; //圆心坐标 double rr; //圆形半径 }; //带参构造函数的类外定义,要求由cen和rad分别初始化cc和rr //********** found********** Circle::______(Point& cen, double rad) //********** found********** ______{rr=rad; } int main() { Point x, y(4,5); Circle a(x,3), b(y,6); //输出两个圆的圆心坐标和半径 a. PrintP (); //********** found********** ______; cout<<a.Area () <<" <<b. Area() <<endl; return 0; }

【参考答案】

(1)cc.PrintP() (2)Circle (3)cc(cen) (4)b.PrintP()