So i overloaded the operator < and tried to reuse this by just returning the complement of it for the > comparison operator.
I have been stuck at this error tho..

error C2679: binary '>' : no operator found which takes a right-hand operand of type 'const Customer' (or there is no acceptable conversion)
1> could be 'built-in C++ operator>(const Customer *, const Customer *)'

Could anyone give me some insight on issue here.. which I am guessing is a pointer/reference problem..
This is the testing method..

void main()
{
	//tester of the Customer class...
	Customer c, d;
	c = Customer("bdbaaa", 'A', 1000);
	d = Customer("bdbaa", 'H', 21100);
	
	if (c  > d)
	{
		cout << "YEH!";
	}

This is the line(s) in the header:
..

bool operator <(const Customer &c) const;
	bool operator >(const Customer  &a) const;

This is the implementation in the cpp..
..

bool Customer::operator <(const Customer & t) const
{
//implementation here... this code for the < operator works perfectly fine..
}
bool Customer::operator >(const Customer &a) const
{
	return !(this > a);
}

The way you wrote it is ambiguous. It could be a recursive reference to itself (which is technically undefined) or a call to one of the compiler's included pre-defined versions of the operator. Either way, I suspect that it does not match your intent.

I'm not sure if it will accept it, but change it to the less-than symbol so that it calls the other, properly-defined, operator.

Edited 6 Years Ago by Fbody: n/a

OH shoot yeah the very last line I didnt realize that I acctually meant to type the less than operator.. Still the same problem nonetheless

The this object is a pointer to the current (in your case) Customer object. It is NOT the object itself.
Try dereferencing the this pointer. That way, it's calling the operator relative to the object, not a pointer to the object.

Edited 6 Years Ago by Fbody: n/a

The this object is a pointer to the current (in your case) Customer object. It is NOT the object itself.
Try dereferencing the this pointer. That way, it's calling the operator relative to the object, not a pointer to the object.

did exactly what you mentioned in your first post,
thanks bro! works

This article has been dead for over six months. Start a new discussion instead.