文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C++ philosophy: Changing the accessibility of a class member should never change

C++ philosophy: Changing the accessibility of a class member should never change

时间:2010-12-20  来源:嗷嗷

代码
#include <iostream>
using std::cout;
using std::endl;
class Base1{
public:
void foo(){cout<< "Base1::foo"<<endl;};
};

class Base2{
private:
void foo(){cout<< "Base1::foo"<<endl;};
};

class Dirived : public Base1,public Base2{};

int main(){
Dirived d;
d.foo();
return 0;
}

 

d.foo();这一行编译器会报错 error: "Dirived::foo" is ambiguous

那么既然,Bas2的foo是一个私有函数,在Dirived类中并不可见,为什么编译器还傻傻的说ambiguous呢?

 

相关阅读 更多 +
排行榜 更多 +
猎枪行动

猎枪行动

飞行射击 下载
导弹袭击

导弹袭击

飞行射击 下载
猫猫突围封锁要塞新手打法

猫猫突围封锁要塞新手打法

飞行射击 下载