关于以下代码,( )行会引起编译错误(Derived 公有继承自 Base,a 私有、b 保护、c 公有)。
class Base {
private: int a;
protected: int b;
public: int c;
Base() : a(1), b(2), c(3) {}
};
class Derived : public Base {
public:
void show() {
cout << a << endl; // Line 1
cout << b << endl; // Line 2
cout << c << endl; // Line 3
}
};
- A. Line 1
- B. Line 2
- C. Line 3
- D. 没有编译错误
正确答案:A