Académique Documents
Professionnel Documents
Culture Documents
* File: 20160912_CPP_L03.cpp.
* Title: 2016-09-12 C++ Lesson 03
* Author: Renato Montes
* Description: Notes for Albert Wei's C++ class
*/
/* Reminder: Manipulators */
cout << hex;
//hex is the name of a function, i.e. a function pointer
//names of functions can be used as function pointers
/* * inheritance */
ios_base
/\
|
basic_ios<> //special name: ios
//<> because it's a class template
/\ /\
| |
basic_istream<> basic_ostream<>
istream ostream
ios_base& hex(ios_base& b) {
b.setf(ios_base::hex, ios_base::basefield);
return b;
}
/* Input */
//Example:
int n;
cin >> n; //y default, >> skips leading white space, similarly to scanf
//We can use the clear() method to put the stream back into a good state.
//Make sure to call clear() after failure.
//It's IMPORTANT to clear()! Or it may not read again!
/* Discarding input */