问题
填空题
程序的输出结果是______。
#include<iostream>
using namespace std;
class Base
int x;
Public:
Base(int B):x(B)
virtual void display( )cout<<x;
;
class Derived:public Base
int y;
public:
Derived(int D):Base(D),y(D)
void display( )cout<<y;
;
int main( )
Base b(1) ;Derived d(2);
Base*p=&d;
b.display( );d.display( );p—>display( );
return 0;
答案
参考答案:122