下面程序的输出结果为:Base:: fun,请将程序补充完整。
include <iostream.h>
class Base{
public:
【 】 fun(){cout<<"Base::fun"<<end1:}
class Derived : public Base{
public:
【 】 fun(){ cout<<"Derived::fun"<<end1; }
};
int main()
{
Base a,*pb;
Derived b;
pb = &b;
pb->fun();
return 0;
}
第1题:
下列程序的输出结果为2,请将程序补充完整。
include<iostream>
using namespace std;
class Base
{
public:
______void fun(){cout<<1;}
};
class Derived:public Base
{
public:
void fun(){cout<<2;}
};
int main()
{
Base*p=new Derived;
p->fur();
delete p;
return 0;
}
第2题:
请将如下程序补充完整,使得输出结果为: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;
}
第3题:
下列程序的输出结果为2,请将程序补充完整。
include <iostream>
using namespaee std;
class Base{
public:
______void fun( ){cout<<1;}
};
class Derived:public Base{
public:
void fun( ){cout<<2;}
};
int main( ){
Base*P=new Derived:
p->fun( );
delete P;
return 0;
}
第4题:
有如下程序:#include <iostream>using namespace std;class Base { public: void fun() {cout<<"Base:: fun"<<end1; }};class Derived: public Base ( public: void fun() { ____________________________ cout<<"Derived:: fun"<<end1; }};int main() { Derived d; D. fun(); return O;}已知其执行后的输出结果为:Base:: funDerived:: fun则程序中下划线处应填入的语句是( )。
A.Base. fun ();
B.Base:: fun ();
C.Base->fun();
D.fun()
第5题:
有如下程序: #include<iostream> using namespace std; class Base { public: void fun() { cout<<"Base::fun"<<endl; } }; class Derived: public Base { public: void tim() } ____________ cout<<"Derived:: fun"<<endl; } }; int main() { Derived d; d.fun(); return O; } 已知其执行后的输出结果为: Base::fun Derived::fun 则程序中下划线处应填入的语句是
A.Base.fun();
B.Base::fun();
C.Base->fun();
D.fun();