题库 软件开发 题目列表 下面代码执行后的输出结果为(      )? #include &l...
单选题
下面代码执行后的输出结果为(      )?
#include <iostream>
using namespace std;

class A{
protected:
    int num;
    
public:
    A(int i){num=i;}    
    A& operator=(const A &a){
        num=a.num;
        return *this;
    }
};

class B:public A{
    double dig;
public:
    B(double d):A(int(d)+1){dig=d;}
    B& operator=(const B&);
        void show(){
        cout << num << "," << dig << endl;
    }
};

B& B::operator =(const B &b){ 
    A::operator=(b);
    dig=b.dig;
    
    return *this;
}

int main(){
    B obj(1.5);
    obj.show();
    return 0;
}
A.

1,1.5

B.

2,1.5

C.

2,1

D.

编译时报错

题目信息
校招真题
-
正确率
0
评论
13
点击