17

单选题 17 /40

下列代码的输出为:
#include<stdio.h>
class CParent {
    public: virtual void Intro(){
        printf( "I'm a Parent, " ); Hobby();
    }
    virtual void Hobby(){
        printf( "I like football!" );
    }
}; 
class CChild : public CParent { 
    public: virtual void Intro(){
        printf( "I'm a Child, " ); Hobby();
    }
    virtual void Hobby(){
       printf( "I like basketball!\n" );
    }
}; 
int main( void ){
    CChild *pChild = new CChild(); 
    CParent *pParent = (CParent *) pChild; 
    pParent->Intro(); 
    return(0);
}

参考答案

I'm a Parent, I like football!
I'm a Parent, I like basketball!
I'm a Child, I like basketball!
I'm a Child, I like football!