C++多继承同名隐藏实例详细介绍

如果某个派生类的部分或者全部直接基类是从另一个共同的基类派生而来,在这些俄直接基类中,
从上一级基类继承来的成员就拥有相同的名称,因此派生类中就会出现同名现象。对这种类型的同名成员也要使用作用域分辨符来唯一标识,而且必须使用直接基类来进行限定。
--------------------------------------------------
/*
* File: main.cpp
* Author: yubao
*
* Created on May 31, 2009, 8:54 AM
*/
#include <iostream>
using namespace std;
class B0
{
public :
int nV;
void fun(){cout<<"member of B0"<<endl;}
};
class B1:public B0
{
public:
int nV1;
};
class B2:public B0
{
public :
int nV2;
};
class D1:public B1,public B2
{
public:
int nVd;
void fun(){cout<<"member of D1"<<endl;}
};

/*
*
*/
int main(int argc, char** argv) {
D1 d1;
d1.B1::nV=2;
d1.B1::fun();
d1.B2::nV=3;
d1.B2::fun();
return 0;
}