单项选择题
有如下程序:
#include <iostream>
using namespace std;
class Base
public:
void output() cout<<1;
virtual void Print() cout<'B';
;
class Derived:public Base
public:
void output() cout<2;
void Print() cout<<'D';
;
int main()
Base *ptr=new Derived;
ptr->output();
ptr->Print();
delete ptr;
return();
程序的输出结果是
A.1B
B.1D
C.2B
D.2D
点击查看答案
<上一题
目录
下一题>
热门
试题
单项选择题
执行以下程序后的输出结果为( )。 #include <iostream> Using namespace std; void fun(int x,int y,int *cp,int *dp) *cp=x+y;*dp=x-y;) void main() int a,b,c,d; a=30; b=50; fun(a,b,&c,&d); cout>>c>>','<<d<<endl;
A.50,30
B.30,50
C.80,-20
D.80,20
点击查看答案
单项选择题
有如下程序: #include <iostream> using namespace std; class point int x,y; public: point( int vx,int vy) x=vx; y=vy; point() x=0; y=0; point operator+(point p1) point p; int px=x+p1.x; int py=y+p1.y; return point(px, py); point operato-(point p1) point p; int px=x-p1.x; int py=y-p1.y; return point(px,py); void print() cout<<x<< , <<y<<endl; ; int main() point p1(10,10), p2(20,20); p1=p1+p2; p1.print(); return 0; 执行后的输出结果是( )a
A.10,10
B.20,20
C.10,20
D.30,30
点击查看答案&解析
相关试题
以下程序段的执行结果为______。 #...
有以下程序 #include <iostream> usi...
下列程序的运行结果是______。 #in...
以下程序的输出结果是______。 #in...
派生类中的成员不能直接访问基类中的___...