Please How can i overload?

0 Teemmy Ellorry · February 8, 2015
int main()
{        
       Ball e, f;
       cout<<"TEST CASE 5 (10 MARKS)"<<endl;
e.setData("Jim","Blue",15);
f.setData("Rita","Gold",14);

if(e > f)
{
cout<<"e > f"<<endl;
}
else
{
cout<<"f < e"<<endl;
}
}
How can I overload the operator  ">" in (e > f)"

Post a Reply

Replies

Oldest  Newest  Rating
+1 Mathias Frits Rørvik · February 8, 2015
In the ball class, add this method.


bool Ball::operator >(Ball cons t& b) {
     //stuff to determine if one ball is greater than the other
     if ( ... ) { return true; } else { return false; }
}
0 Teemmy Ellorry · February 12, 2015
Thanks Alot... Now working....
  • 1

C++

107,259 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator