第32434题 单选题
有如下C++代码,main函数中的以下访问操作,合法的是哪一项?
#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;

程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析