< previous page page_140 next page >

Page 140
(table continued from previous page)
2.a.gif B\n
CD\n
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
cin.get(ch1);
ch1 =AAsbox.gif B\n
CD\n
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
cin.get(ch2);
ch2 =Ab.gif \n
CD\n
cin.get(ch3);ch3 =BA Bslashn.gif
CD\n
3.a.gif B\n
CD\n
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
cin >> ch1;
ch1 =AAsbox.gif B\n
CD\n
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
cin >> ch2;
ch2 =BA Bslashn.gif
CD\n
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
cin.get(ch3);
ch3 = \nA B\n
c.gif D\n

You may be puzzled about the peculiar syntax in a function call like
cin.get(ch1);
This statement uses a C++ notation called dot notation. There is a dot (period) between the variable name cin and the function name get. Certain predefined data types, like istream and ostream, have functions that are tightly associated with them, and dot notation is required in the function calls. If you forget to use dot notation by using
get(ch1);
you get a compile-time error message, something like UNDECLARED IDENTIFIER. The compiler thinks you are trying to call an ordinary function named get, not the get function associated with the istream type.
Another example you saw in the last chapter is the function call that forces decimal points to appear in the output of all floating point numbers:
cout.setf(ios::showpoint);

 
< previous page page_140 next page >