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?

Implement mini version of linux ''tar'', I need to implement a mini version...

I need to implement a mini version of linux''s ''tar'' function in C.

Create a program that converts numbers to characters, People sometimes give...

People sometimes give their phone numbers using one or more alphabetic characters. Create a program that converts the alphabetic characters to their corresponding numbers. For exam

MCQ, in a multilist organisation

in a multilist organisation

How to use http headers inside php, How to use HTTP Headers inside PHP? Wri...

How to use HTTP Headers inside PHP? Write the statement through which it can be added? HTTP headers can be used in PHP by redirection that is written as: Headers can be

Program for function in cpp, Question Write a program using c++ for the...

Question Write a program using c++ for the above function , at a= 1000, b=10 -3 ,10 -2 ,10 -4

Luminous jewel polishing neckiace, Byteland county is very famous for lumin...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

How do i develop a subscript operator for a matrix class?, Employ operator ...

Employ operator () instead of operator[]. While you have multiple subscripts, the cleanest way to do it is along with operator () instead of with operator[]. The reason is that

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