Following is the definition for a class called Percent. Objects of type Percent represent percentages such as 10% or 99%. Give the definitions of the overloaded operators >> and input and output with...


Following is the definition for a class called Percent. Objects of type


Percent represent percentages such as 10% or 99%. Give the definitions


of the overloaded operators >> and <>


input and output with objects of the class Percent. Assume that input


always consists of an integer followed by the character ‘%’, such as 25%. All


percentages are whole numbers and are stored in the int member variable


named value. You do not need to define the other overloaded operators


and do not need to define the constructor. You only have to define the


overloaded operators >> and


#include


using namespace std;


class Percent


{


public:


 friend bool operator ==(const Percent& first,


const Percent& second);


 friend bool operator <(const>


const Percent& second);


 Percent();


 Percent(int percentValue);


friend istream& operator >>(istream& ins,


 Percent& theObject);


 //Overloads the >> operator to input values of type


 //Percent.


 //Precondition: If ins is a file input stream, then ins


 //has already been connected to a file.


 friend ostream& operator


 const Percent& aPercent);


 //Overloads the <>


 //Percent.


 //Precondition: If outs is a file output stream, then


 //outs has already been connected to a file.


private:


 int value;


};



May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here