Pure opEquals in a class

werter werter at gmail.com
Mon Aug 20 19:36:15 UTC 2018


The code below doesn't work. Is it possible to make a pure 
opEquals in a class?

void main()
{
	class A
	{
		bool a;
		int b;
		
		this(bool g, int h)
		{
			a = g;
			b = h;
		}
				
		pure bool opEquals(const A rhs) const
		{
			return b == rhs.b;	
		}		
	}
		
	A a = new A(true, 5);
	A b = new A(false, 5);
	
	assert(a == b); //fails
}


More information about the Digitalmars-d-learn mailing list