istream& ComplexNum::input(istream& in)
{
cout << "Enter real: ";
return in >> real >> imaginary;
}
I have an overloaded input stream operator ">>" and I wanted to have a message before each keyboard request for value inside "real" and "imaginary" which are part of a class called ComplexNum. So, the console would display:
"Enter the real number: " //real number entered from keyboard here
"Enter the imaginary number: " //imaginary number entered from keyboard here
Currently, I have only been able to manipulate it from inside the main, but in the main, I can only get it to say something like, "Enter real & imaginary parts:" and won't allow me to break down the request for the whole Complex Number into two parts (which is both a real and imaginary number). Does this make sense?
I guess what I'm asking is...is there a way to break up the return statement to include cout statements that notify the user what she/he is inputting? I don't want it to say: "Enter a complex number" and leave the user confused as to why entering, say, "4" doesn't give positive feedback in the form of asking for the imaginary number...instead it's just a blank cursor that's waiting for the imaginary keyboard input.
cout << "Enter real: ";
return in >> real;
cout << "Enter the imaginary number: ";
return in >> imaginary;
You can imagine how much headache this was causing me. In an attempt to get two messages I was doing the most counterintuitive thing which is breaking up the return statement... Enjoy the rest of your week!