Download this source file
// Example of using temporary objects with iostreams. This idea comes from
// Jerry Schwarz, the creator of the initial iostream classes. (Reference
// fround in B. Eckle's "Thinking in C++", Prentice Hall, 1995, pp 248-ff.)
// He calls the technique "Effectors". The basic idea is to create a
// manipulator that take arguments as simple class whose constructor take
// arguments, and which has an inserter or extractor (or both).
//
// Written by Wayne Pollock, Tampa FL, 2000.
#include
#include
#include
using namespace std;
// This manipulator will output a string with all lowercase
// letters translated into uppercase:
class upcase
{
public:
upcase ( const char* s )
{ int l = strlen( s );
rep = new char[l + 1];
strcpy( rep, s );
for ( int i=0; i