// ̳.cpp : ̨Ӧóڵ㡣
//

#include "stdafx.h"
#include "iostream"
using namespace std;


	class A
	{
	public:	
		int x ;
		A()
		{
			x = 1;
		};

		void print() 
		{
			cout<<x<<endl;
		}
	
	};
	 class B:public A
	{
	public:	
		B() 
		{
			x = 2;
		};

		void print() 
		{
			cout<<x<<endl;
		}
	};
	class C:public A
	{
	public:	
		C()
		{
			x = 3;
		};

		void print() 
		{
			cout<<x<<endl;
		}
	};
	class D:public B,public C
	{
	
	};

int _tmain(int argc, _TCHAR* argv[])
{

	D dd;

	dd.A::print();     //2
	dd.B::print();     //2
	dd.C::print();     //3
	dd.C::A::print();  //3

	//dd.print();      //error C2385: ambiguous access of 'print'
	                   //error C3861: 'print': identifier not found

	//cout<<dd.x;     //error C2385: ambiguous access of 'x'
	cout<<dd.A::x<<endl;       //2
	cout<<dd.B::x<<endl;       //2
	cout<<dd.C::x<<endl;       //3
	cout<<dd.B::A::x<<endl;    //2

	return 0;
	system("pause");
}

