问题
单项选择题
有如下程序:
#include <iostream>
using namespace std;
class Base
public:
void fun1() cout<<"Base\n";
virtual void fun2() cout<<"Base\n";
;
class Derived: public Base
public:
void fun1() cout<<"Derived\n";
void fun2() cout<<"Derived\n";
;
void f(Base&b) b.fun1(); b.fun2();
int main()
Derived obj;
f(obj);
return 0;
执行这个程序的输出结果是( )。
A.Base
Base
B.Base
Derived
C.Derived
Base
D.Derived
Derived
答案
参考答案:B