单选题

下面代码执行后的输出结果为()?#include<iostream&...

发布于 2022-03-03 14:01:01

下面代码执行后的输出结果为(      )?
#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
}

登录后免费查看答案
关注者
0
被浏览
15
知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看