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 >
Wrap
Text File
|
1992-09-08
|
699b
|
48 lines
***************************************************
// Listing 4 - MANIPT.CPP
#include <iostream.h>
/* 1 argument template */
template <class T>
class omanip1
{
ostream& (*_fn)(ostream&,T);
T a1;
public:
omanip1(ostream& (*_f)(ostream&, T), T _a1) :
_fn(_f), a1(_a1)
{
};
friend ostream& operator<<(ostream& _s,omanip1& _f)
{
return (*_f._fn)(_s,_f.a1);
};
};
/* Action function */
static ostream& tem_test(ostream &o, int a)
{
o<<"Template test="<<a<<"!!";
return o;
}
/* Manipulator function */
omanip1<int> mytest(int i)
{
omanip1<int> rv(mytest,i);
return rv;
}
/* Simple test program */
main()
{
cout<<mytest(10)<<"\n";
}