Describe, how can i provide input for my class fred?, C/C++ Programming

Assignment Help:

A: Use operator overloading to present a friend right-shift operator, operator>>. It is similar to the output operator, except the parameter doesn't contain a const: "Fred&" instead of "const Fred&".

#include class Fred {

public:

friend std::istream& operator>> (std::istream& i, Fred& fred);

... private:

int i_; // Just for illustration

};

std::istream& operator>> (std::istream& i, Fred& fred)

{

return i >> fred.i_;

}

int main()

{

Fred f;

std::cout << "Enter a Fred object: ";

std::cin >> f;

...

}

Note  down that operator>> returns the stream. It is so the input operations may be cascaded and/or utilized in a while loop or if statement.

 


Related Discussions:- Describe, how can i provide input for my class fred?

Change to palindrome, A palindrome is a string that reads the same from bot...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Car rental project, I need a project on car rental system using c programmi...

I need a project on car rental system using c programming only of college level

Harcourt social studies, how would land elevation have changed if Coronado ...

how would land elevation have changed if Coronado had traveled 150 miles due west from what is today Arizona instead of east toward New Mexico

Working of ordered linked list, Working Ordered linked list: • Eachint...

Working Ordered linked list: • Eachinteger in the queue is stored inside of a QueueItem. The QueueItem contains the integer, and a pointer to the next item in the queue. Fo

What is scope resolution operator, Scope Resolution operator: The scope...

Scope Resolution operator: The scope resolution operator: : is used to access global variable in the inner block. When global and local variable are identical name the scope re

Convert a cov-cpe file to a tif image file, Convert a COV/CPE (Micosoft Fax...

Convert a COV/CPE (Micosoft Fax Cover Page) file to a TIF image file Project Description: I would like a small API written that will take a COV/CPE file and replaced the corr

Functions and stack frame, Each function has its own stack frame between %f...

Each function has its own stack frame between %fp and %sp. Let Caller calls Callee. Then Caller's %sp becomes callee's %fp, and callee's %sp set to be a new value (a smaller one be

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd