[单选题]

有如下程序:

#include +

using namespace std ;

#include

using namespace std;

class Base

{

public:

void fun(){cout<<"Base::fun"<

};

class Derived:public Base

{

public:

void fun()

{

cout<<"Derived::fun"<

}

};

int main()

{

D.erived d;

d.fun();

return 0;

}

已知其执行后的输出结果为:

B.ase::fun

D.erived::fun

则程序中下划线处应填入的语句是

A. . Base.fun();

B. . Base::fun()

C. . Base->fun()

D. . fun();

参考答案与解析:

相关试题

有如下程序:#include using namespace std;using

[单选题]有如下程序:include using namespace std;using namespace std;class Base{public:vo有如下程序: #include <iostream> using namespace std; using namespace std; class Base{ public: void fun( ){cout<<"Base::fun"<<endl:} }; class Derived:public Base{ public: void fun(

  • 查看答案
  • 有如下程序: #include using namespace std; in

    [单选题]有如下程序: include using namespace std; int main() { char st有如下程序: #include <iostream> using namespace std; int main() { char str[100], *p; cout<<"Please input a string:"; cin>>str; p=str; for (int i=0; *p!='/0'; p++,i++); cout<<i<<endl; return 0; }

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class BASE { public有如下程序: #include<iostream> using namespace std; class BASE { public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE { public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVEDx;retum 0;}

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class A { public:有如下程序: #include<iostream> using namespace std; class A { public: A(){cout<<"A";} }; class B<public:B(){cout<<"B";)); class C:public A { B b; public: C(){cout<<"C";} }; int main(){Cobj;retum 0

  • 查看答案
  • 有如下程序: #include using namespace std; int

    [单选题]有如下程序: include using namespace std; int main() { cout.f有如下程序: #include<iostream> using namespace std; int main() { cout.fill('*') cout.width(6); cout.fill('#') cout<<123<<endl; return 0; } 执行后的输出结果是A.###123B.123###C.***123D.123***

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class AA { int n;有如下程序: #include<iostream> using namespace std; class AA { int n; public: AA(int k);n(k){} intget(){return n;} int get()const{return n+1;} }; int main() { AA a(5); const AA b(6); cout<<a.get()<<b.ge

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class Test { public有如下程序: #include<iostream> using namespace std; class Test { public: Test(){n+=2;} ~Test(){n-=3;} static int getNum(){return n;} private: static int n; }; int Tesl::n=1 int main() { Test*p=new Tes

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class Base{ int x; pu有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;) int getX()const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class Amount{ int amount有如下程序: #include<iostream> using namespace std; class Amount{ int amount; public: Amount(int n=0):amount(n){} int getAmount()const{return amount;} Amount&operator9=(Amount a){ amount+=a.

  • 查看答案
  • 有如下程序: #include using namespace std; cl

    [单选题]有如下程序: include using namespace std; class Obj { static in有如下程序: #include <iostream> using namespace std; class Obj { static int i; public: Obj( ){i++;} ~Obj(){i--;} static int getVal( ){ return i;} }; int Obj::i=0; void f() {Obj ob2; cout<<ob2.getVa

  • 查看答案
  • 有如下程序:#include £«using namespace std ;#i