| | | | | |

I/O Manipulators with Parameters - 3

    // manipulator for setting width
    class SetWidth
    {
      public:
        SetWidth(int width) : width_(width)
        {}
        void operator() (std::ios_base& s)
        {
          s.width(width_);
        }
      private:
        int width_;
    };
    
    // useage:
    os << SetWidth(8) <<  x;
    is >> SetWidth(8) >>  y;
    

| | Top of Page | 5. Function Classes & - 10 of 11