Question: In C++: When overloading the output and input operators, we cannot make the operator a member of our own class. If we did, then the

In C++: When overloading the output and input operators, we cannot makeIn C++:

When overloading the output and input operators, we cannot make the operator a member of our own class. If we did, then the left-hand operand would have to be an object of our class type. One more important difference between input and output operators is that input operators must deal with the possibility of errors and end-of- file. Write an input stream overloaded operator (that's the >> one) for the given class, and read into the member variables from a istream object. Assume the data is in the order of indexNumber, items, and cost (with space separation between them). Next, check to verify that the streaming from the istream input object was successful, and if so, compute member total by multiplying items by cost. If the input failed then reset the object (think how to do this given the definition). class myBusiness { friend std::istream& operator>>(std::stream &, myBusiness &); public: myBusiness(): indexNumber(0), items(0), cost(0.0) }; private: int indexNumber; int items; float cost; float total

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!