| | | | | next -> |

I/O Manipulators with Parameters - 4

  • Useage:
  • os << SetWidth(8) << x;
    
  • Sequence of events:
    1. temporary SetWidth(8) object created (call it "temp")
    2. operator<< called with arguments (os, temp)
    3. temp(os) called, that is:
    4. temp.operator() called with argument os
    5. os.width(8) called
    6. object temp goes out of scope
    7. operator<< returns reference to os for application of os << x
  • Can also be applied to input:
  • is >> SetWidth(20) >> y;
    

| next -> | Top of Page | 5. Function Classes & - 11 of 11