有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;} int

admin2013-02-27  9

问题 有如下程序:    #include<iostream>    using namespace std;    class Base{    int x;    public:    Base(int n=0):x(n){cout<<n;}    int getX( )const{return x;}    };    class Derived:public Base{    int y;    public:    Derived(int m,int n):y(m),Base(n){tout<<m;}    Derived(int m):y(m){cout<<m;}    };    int main( ){    Derived dl(3),d2(5,7);    return 0;    }    程序的输出结果是   

选项 A、375
B、357
C、0375
D、0357

答案C

解析 有如下程序:    #include<iostream>    using namespace std;    class Base{    int x;    public:    Base(int n=0):x(n){cout<<n;}    int getX( )const{return x;}    };    class Derived:public Base{    int y;    public:    Derived(int m,int n):y(m),Base(n){tout<<m;}    Derived(int m):y(m){cout<<m;}    };    int main( ){    Derived dl(3),d2(5,7);    return 0;    }    程序的输出结果是   
转载请注明原文地址:https://kaotiyun.com/show/0qVp777K
0

最新回复(0)