// ̳.cpp : Defines the entry point for the console application.
//


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


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

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

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

		void print() 
		{
			cout<<x<<endl;
		}
	};


	class D:virtual public B,virtual public C
	{
	
	};

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

	D dd;

	dd.A::print();     //3
	dd.B::print();     //3
	dd.B::A::print();  //3
	dd.C::print();     //3
	//dd.print();    //error C2385: ambiguous access of 'print'
	                 //error C3861: 'print': identifier not found
	cout<<dd.x<<endl;  //3
	cout<<dd.A::x<<endl;       //3
	cout<<dd.B::x<<endl;       //3
	cout<<dd.C::x<<endl;       //3
	cout<<dd.C::A::x<<endl;    //3
	return 0;
	system("pause");
}

