//产生两义性问题的例程如下:
/*
#include<iostream>
using namespace std;
class A
{
public:
void hello(){cout<<"基类A的hello函数"<<endl;}
};
class B
{
public:
void hello(){cout<<"基类B的hello函数"<<endl;}
};
class C:public A,public B
{
public:
void hello(){cout<<"子类C的hello函数"<<endl;}
};
void main()
{
C c;
c.A::hello(); //基类A的hello函数(成员名限定由类名A加域操作符::组成)
c.B::hello(); //基类B的hello函数
c.hello(); //子类C的hello函数 编译器都是从离自己最近的目录树向上搜索的,因为类C定义了hello 函数所以闲搜索到对象C的hello 函数
}
*/
/*
#include<iostream>
using namespace std;
class A
{
public:
void hello(){cout<<"基类A的hello函数"<<endl;}
};
class B
{
public:
void hello(){cout<<"基类B的hello函数"<<endl;}
};
class C:public A,public B
{
public:
void hello(){cout<<"子类C的hello函数"<<endl;}
};
void main()
{
C c;
c.A::hello(); //基类A的hello函数(成员名限定由类名A加域操作符::组成)
c.B::hello(); //基类B的hello函数
c.hello(); //子类C的hello函数 编译器都是从离自己最近的目录树向上搜索的,因为类C定义了hello 函数所以闲搜索到对象C的hello 函数
}
*/