Hello senior2, I'm still dummy in C++. There are something that i want to ask.
There is a little program my lecturer gave.
#include <iostream.h>
#include <iomanip.h>
class PhoneNumber
{
friend ostream &operator<<( ostream&, const PhoneNumber & ); (***)
friend istream &operator>>( istream&, PhoneNumber & ); (***)
private:
char areaCode[ 4 ];
char exchange[ 4 ];
char line[ 5 ];
};
ostream &operator<<( ostream &output, const PhoneNumber &num ) (***)
{ output << "(" << num.areaCode << ") " (***)
<< num.exchange << "-" << num.line; (***)
return output;
}
istream &operator>>( istream &input, PhoneNumber &num ) (***)
{
input.ignore(); (***)
input >> setw( 4 ) >> num.areaCode; (***)
input.ignore( 2 ); (***)
input >> setw( 4 ) >> num.exchange; (***)
input.ignore(); (***)
input >> setw( 5 ) >> num.line; (***)
return input; (***)
}
void main()
{ PhoneNumber phone; // create object phone
cout << "Enter phone number in the form (123) 456-7890:\n";
cin >> phone;
(***)
cout << "The phone number entered was: ";
cout << phone << endl; (***)
}
Please give a comment or explanation in the line that i noted with (***), because i don't understand.
For line that un-noted, I already knew teh meaning of that line.
Thanks before for the answer Senior...