#include <cstdlib>
#include <iostream>

//////////////////////////////////////////////////////////////////////////////////

struct Base1
{
	Base1( unsigned& val ) : m_val( val ){}
	bool operator==( const Base1& rhs )const { return m_val == rhs.m_val; }
	unsigned& m_val;
};

//////////////////////////////////////////////////////////////////////////////////

struct Base2
{
	Base2( unsigned& val ) : m_val( val ){}
	bool operator==( const Base2& rhs ) const { return m_val == rhs.m_val; }
	unsigned& m_val;
};

//////////////////////////////////////////////////////////////////////////////////

class Derived : public Base1 , public Base2		// Real problem has many more more Base classes
{
public:
	Derived( unsigned& val1 , unsigned& val2 ) : Base1( val1 ) , Base2( val2 )
	{
	}
	
	bool operator==( const Derived& rhs ) const	// How to generalize this 
	{
		const Base1& rhsBase1 = rhs;
		const Base2& rhsBase2 = rhs;
		
		const Base1& thisBase1 = *this;
		const Base2& thisBase2 = *this;
		
		return ( thisBase1 == rhsBase1 ) && ( thisBase2 == rhsBase2 );
	}
};

//////////////////////////////////////////////////////////////////////////////////

int main()
{
	unsigned val1 = 42 , val2 = 24 , val3 = 0;
	Derived d1( val1 , val2 );
	Derived d2( val1 , val3 );

	std::cout << ( d1 == d2 ) << std::endl;
	return EXIT_SUCCESS;
}

//////////////////////////////////////////////////////////////////////////////////