Sunday, July 26, 2009

Need help with my C++ homework?

Could someone please explain the %26gt; and %26lt; part to me? and maybe how to tell which overloaded function is called when?





#include "Lake.h"





class CustomLake : public Lake


{


private:


int holeNumber;


public:


CustomLake();


void setHoleNumber(int h){holeNumber=h;}


int getHoleNumber(){ return holeNumber;}


bool operator %26gt; (CustomLake cl);


bool operator %26lt; (CustomLake cl);


bool operator %26gt;%26gt; (CustomLake cl);


bool operator %26lt;%26lt; (CustomLake cl);


};





#include "CustomLake.h"


CustomLake::CustomLake()


{


holeNumber=1;


}


bool CustomLake::operator %26gt; (CustomLake cl)


{


if(holeNumber%26gt;cl.holeNumber)


return true;


else


return false;


}


bool CustomLake::operator %26lt; (CustomLake cl)


{


if(holeNumber%26lt;cl.holeNumber)


return true;


else


return false;


}


bool CustomLake::operator %26gt;%26gt; (CustomLake cl)


{


if(fillTime%26gt;cl.fillTime)


return true;


else


return false;


}


bool CustomLake::operator %26lt;%26lt; (CustomLake cl)


{


if(fillTime%26lt;cl.fillTime)


return true;


else


return false;


}

Need help with my C++ homework?
You are defining what the less than greater than symbols mean in relation to the customlake class. So you can compare them based on your definition (not shown).
Reply:If C %26lt; D


means C.%26lt;(D)


No comments:

Post a Comment