home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_11 / 1011050a < prev    next >
Text File  |  1992-09-08  |  699b  |  48 lines

  1.  
  2. ***************************************************
  3.  
  4. // Listing 4 - MANIPT.CPP
  5. #include <iostream.h>
  6.  
  7. /* 1 argument template */
  8. template <class T>
  9. class omanip1
  10.   {
  11.   ostream& (*_fn)(ostream&,T);
  12.   T a1;
  13.  
  14. public:
  15.   omanip1(ostream& (*_f)(ostream&, T), T _a1) :
  16.           _fn(_f), a1(_a1)
  17.    {
  18.    };
  19.  
  20.   friend ostream& operator<<(ostream& _s,omanip1& _f)
  21.     {
  22.     return (*_f._fn)(_s,_f.a1);
  23.     };
  24.  };
  25.  
  26. /* Action function */
  27. static ostream& tem_test(ostream &o, int a)
  28.   {
  29.   o<<"Template test="<<a<<"!!";
  30.   return o;
  31.   }
  32.  
  33. /* Manipulator function */
  34. omanip1<int> mytest(int i)
  35.   {
  36.   omanip1<int> rv(mytest,i);
  37.   return rv;
  38.   }
  39.  
  40.  
  41. /* Simple test program */
  42. main()
  43.   {
  44.   cout<<mytest(10)<<"\n";
  45.   }
  46.  
  47.  
  48.