问答题
【参考答案】
①virtual void setx(int i,int j=0){x=i;y=j;}
②virt......
(↓↓↓ 点击下方‘点击查看答案’看完整答案、解析 ↓↓↓)
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
问答题
使用VC6打开考生文件夹下的工程RevProj14。此工程包含一个源程序文件RevMain14.cpp,但该程序中类的定义有错误。请改正程序中的错误,使它能得到正确结果。 注意,不要改动main函数,不得删行或增行,也不得更改程序的结构。 源程序文件RevMain14.cpp中的程序清单如下: RevMain14.cpp #include<iostream> #include<math> using namespace std; class Point private: double x; double y; public: Point() void Point(double x1,double y1) x=x1; y=y1; void setvalue(double x,double y) x=x; y=y; double getx () return x; double gety() return y; void print() cout<< x= <<x<< ,y= <<y<<end1; ~Point() ; class Line private: Point p1; Point p2; double width; public: Line(double x1,double y1,double x2,double y2,double d) :p1(x1,y1),p2(x2,y2) width=d; ~Line() void displength() double 1; 1=sqrt((p1.getx)-p2.getx())*(p1.getx()-p2-getx())+ (p1.gety()-p2.gety())*(p1.gety()-p2.gety())); cout<< the length of Line is <<1<<end1; ; int main() Line *p1; Line 1(5,15,25,35,0.5); p1=&1; p1->displength(); return 0;
点击查看答案&解析
问答题
请编写一个函数fun(),它的功能是求出一个正整数的所有因子。例如,若输入72, 则程序应该输出:72=2*2*2*3*3。注意:部分源程序已存在文件PROC14。CPP中。请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句。 文件PROC14.cpp的内容如下: PROC14. cpp #include <iostream> using namespace std; void fun(int number); int main ( ) int n; cout<< Please enter a number n ; cin>>n; cout<<n<< = ; fun (n); return 0; void fun(int number) * * * * * * *
点击查看答案&解析
相关试题
使用VC6打开考生文件夹下的工程RevProj1...
请编写一个函数fun(),它的功能是求出一...