Lecture 3 - Slide 17 : 27
Overloaded operators and IO
Choosing existing operators for IO purposes
The
assignment
operator was considered
x = cin
and
cout = y
Its association to the right is inappropriate
The
less than
and
greater than
operators were considered
cin > x
and
cout < y
Unreadable, and confusing
The
left shift
and
right shift
operators were choosen
cin >> x
and
cout << y
The relative low priority of
<<
is practical when values of expressions must be printed.
cout << x + y * z
and not
cout << (x + y * z)
The C++ Prog. Lang. (3. edition)
:
Page 121-122: operator priorities
The C++ Prog. Lang. (4. edition)
: Page 255-257: operator priorities