选择题 9.  有如下程序:
    #include<iostream>
    using namespace std;
    class GA{
    public;
    virtual int f(){return 1;}
    };
    class GB:public GA{
    public;
    virtual int f(){return 2;}
    };
    void show(GA g){cout<<g.f();}
    void display(GA &g){cout<<g.f();)
    int main(){
    GA a:show(a);display(a);
    GB b:show(b);display(b);
    return 0;
    }
    运行时的输出结果是______。
【正确答案】 C
【答案解析】 此题考查派生类与虚函数的考查。由主函数main入手,其中分别定义了类GA和GB的对象a和b。首先,执行参数a的show函数调用,其中的输出语句为调用GA类中的f()虚函数,返回1。同理display(a)函数输出1。show(b)函数中调用的为GA中的f()函数,display(b)调用GA中f()函数,返回1,display(b)调用GB中的f()函数返回2。所以最后输出为1112。