( 35 ) 有如下程序
#include
using namespace std;
class A{
public:
virtual void func1( ){ cout<<"A1"; }
void func2( ){ cout<<"A2"; }
};
class B:public A{
public:
void func1( ){ cout<<"B1"; }
void func2( ){ cout<<"B2"; }
};
int main( ){
A *p=new B;
p->func1( );
p->func2( );
return 0;
}
运行此程序 , 屏幕上将显示输出
A) B1B2
B) A1A2
C) B1A2
D) A1B2
第1题:
有如下程序: #include<iostream>#include<iosream> using namespace std; class BASE{ char c; public; BASE(char n):c(n){} virtual ~ BASE(){cout<<c;} }; class DERIVED; public BASE{ char c; public: DERIVED (char n): BASE (n+1)
A.XY
B.YX
C.X
D.Y
第2题:
有以下程序: #include <iostream> using namespace std; class BASE { private: char c; public: BASE(char n):c(n);{} virtual~BASE() { cout<<c; } }; class DERIVED:public BASE { char c; p
A.XY
B.YX
C.X
D.Y
第3题:
第4题:
请将如下程序补充完整,使得输出结果为:bbaa。
include<iostream>
using naluespace std;
class A{
public:
______{eout<<"aa";}
};
class B:public A{
public:
~B( ){eont<<"bb";}
};
int ulain( ){
B*P=new B;
delete P;
return 0;
}
第5题:
有如下程序: #include<iostream> using namespace std; class B{ public: Virtual void show(){cout<<“B”;} }; class D:publicB{ public: void show(){cout<<“D”;} }; void funl(B*ptr){ptr->show();} void{un2(B&ref){ref.show();} void
A.BBB
B.BBD
C.DBB
D.DBD
第6题: