// Justin C. Miller
// University of Wisconsin Oshkosh
// Made for: http://www.geocities.com/neonprimetime.geo/index.html
// Date: 2001
// Borland Builder 4.0
// overloaded > , < , >= , <=
#include
#include
class Person
{
private:
char * name ;
int weight ;
public:
Person() ;
void SetInfo(char*, int) ;
bool operator>(const Person & ) const ;
bool operator>=(const Person & ) const ;
bool operator<(const Person & ) const ;
bool operator<=(const Person & ) const ;
} ;
Person::Person()
{name = new char[30] ; weight = 0 ;}
void Person::SetInfo(char * n , int w)
{strcpy(name, n) ; weight = w ;}
bool Person::operator>(const Person & aPerson) const
{return (weight > aPerson.weight) ;}
bool Person::operator>=(const Person & aPerson) const
{ return (weight >= aPerson.weight) ;}
bool Person::operator<(const Person & aPerson) const
{ return (weight < aPerson.weight) ;}
bool Person::operator<=(const Person & aPerson) const
{ return (weight <= aPerson.weight) ;}
int main()
{
Person Jackie ;
Jackie.SetInfo("Jackie", 110) ;
Person Pam ;
Pam.SetInfo("Pam", 110) ;
Person Bubba ;
Bubba.SetInfo("Bubba", 300) ;
if(Jackie < Bubba)
cout << "Jackie weighs less than bubba." << endl ;
else
cout << "Jackie doesn't weigh less than bubba." << endl ;
if(Jackie <= Pam)
cout << "Jackie either ways less than Pam or weighs the same." << endl ;
else
cout << "Jackie doesn't way less than or equal to Pam." << endl ;
if(Bubba > Pam)
cout << "Bubba weights more than Pam." << endl ;
else
cout << "Bubba doesn't weigh more than Pam." << endl ;
if(Bubba >= Jackie)
cout << "Bubba weighs more or is equal to Jackie's weight." << endl ;
else
cout << "Bubba doesn't weight more or the same as Jackie." << endl ;
getch() ;
return 0 ;
}
//OUTPUT
//
// Jackie weighs less than bubba.
// Jackie either ways less than Pam or weighs the same.
// Bubba weights more than Pam.
// Bubba weighs more or is equal to Jackie's weight.
//
               (
geocities.com/neonprimetime.geo/cpp)                   (
geocities.com/neonprimetime.geo)