单项选择题
有如下程序:
#include<iostream>
using namespace std;
class Base
public:
void output( )cout<<l;
virtual void Print( )cout<<’B’;
;
class Derived:public Base
public:
void output( )cout<<1;
void Print( )cout<<’D’;
;
int main( )
Base*prt=new Derived;
prt->output( );
prt->Print( );
delete prt;
return 0;
程序的输出结果是
A.1B
B.1D
C.2B
D.2D
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
若有如下类定义: class B void fun1( ) private: double varl; public: void fun2( ) ; class D:public B private: void fun3( ) ; 已知obj是类D的对象,下列语句中不违反类成员访问控制权限的是
A.obj.fun1( );
B.obj.varl;
C.obj.fun2( );
D.obj.fun3( );
点击查看答案&解析
单项选择题
有如下程序: #include<iostream> using namespace std; class Part public: Part(int x=0):val(x)cout ~Part( )cout<<val; pritave: int val; ; class Whole public: Whole(int x,int Y,int z=0):p2(x),p1(Y),val(z)cout<<val; ~Whole( )cout<<val; pritave: Part p1,p2; int val; f; int main( ) Whole obj(1,2,3); return 0; 程序的输出结果是
A.123321
B.213312
C.213
D.123123
点击查看答案&解析
相关试题
有如下程序: #include<iostream> usi...