首页 > 试题广场 >

阅读该程序,给出程序的输出结果。

[问答题]

阅读该程序,给出程序的输出结果。

#include <iostream.h>

class A

{

public:

    virtual void fun()

    {

        cout<<"A::fun() called.\n";

    }

};

class B:public A

{

    void fun()

    {

        cout<<"B::fun() called.\n";

    }

};

void ffun(A *pa)

{

    pa->fun();

}

void main()

{

    A *pa=new A;

    ffun(pa);

    B *pb=new B;

    ffun(pb);

}
A::fun() called.
B::fun() called.
发表于 2017-09-22 01:15:53 回复(0)