问题
单项选择题
有如下程序:
#include<iostream>
using namespace std;
class Base
private:
void funl( )constcout<<"funl";
protected:
void fun2( )consttout<<"fun2";
public:
void fun3( )consteout<<"fun3";
;
class Derived:protected Base
public:
void fun4( )constcout<<"fun4";
;
int main( )
Derived obj;
obj.funl( ); //①
obj.fun2( ); //②
obj.fun3( ); //③
obj.fun4( ); //④
return 0;
其中有语法错误的语句是
A.①②③④
B.①②③
C.②③④
D.①④
答案
参考答案:B
解析: 使用保护方式派生,派生类对象不可访问基类中的任何成员。