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?

Friend funtion.., Is friend function can be harmfull to make a secure progr...

Is friend function can be harmfull to make a secure program/sofware?

Equation, My project is compiling but the equation entered is not working

My project is compiling but the equation entered is not working

Area Under Curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

#calculate percentge, #write a multilevel c++ program to take marks of 3 su...

#write a multilevel c++ program to take marks of 3 subjects and calculate percentage and display it

Substitution model, (a) Write a procedure called (mult x y) that multiplies...

(a) Write a procedure called (mult x y) that multiplies two numbers x and y in a recursive manner using successive addition. Specifically, note that a x b = a + a + .... + a (b tim

Pebble merchant, there is a pebble merchant. he sells the pebbles,that are ...

there is a pebble merchant. he sells the pebbles,that are used for shining the floor.his main duty is to take the length of the room side but he sometines mistakes doing that and m

Webcam driver static library or dll required for windows, Webcam Driver sta...

Webcam Driver static library or DLL required for Windows I want a .dll or .lib file using which i will take a snapshot from the webcam and it can't turn on the webcam LED while

Explain the scope resolution operator, The Scope Resolution Operator( :: ) ...

The Scope Resolution Operator( :: ) Global variables are explained outside any functions and thus can be used by all the functions defined thereafter. However, if a global vari

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