有如下C++代码,main函数中的以下访问操作,合法的是哪一项?

fm884796 单选题 共 个子题
#include <iostream>
using namespace std;
class Base {
public:
    int a = 1;
protected:
    int b = 2;
private:
    int c = 3;
};
// 公有继承
class Derive1 : public Base {};
// 保护继承
class Derive2 : protected Base {};
// 私有继承
class Derive3 : private Base {};

int main() {
    Derive1 d1;
    Derive2 d2;
    Derive3 d3;
    // 以下为待判断的访问操作
}
A

cout << d1.a << endl;

B

cout << d1.b << endl;

C

cout << d2.a << endl;

D

cout << d3.a << endl;

正在加载题目数据…
已答 /
子题
该题型需在试卷/作业中作答,单题练习暂不支持
答案解析
讨论
发布
登录后参与讨论 立即登录
发布讨论需先绑定并验证手机号 去绑定手机号
加载中…
我
我
回复 @
回复 @
发送
还没有人讨论,来发表第一条吧