Category : C++ Source Code
Archive   : TI1544.ZIP
Filename : TI1544.ASC

 
Output of file : TI1544.ASC contained in archive : TI1544.ZIP







PRODUCT : Borland C++ NUMBER : 1544
VERSION : All
OS : All
DATE : July 19, 1993 PAGE : 1/2

TITLE : Creating an ostream manipulator





// Making an ostream manipulator with BC 3.1 (works for
// previous C++ compilers as well)

#include
#include

typedef char * charptr;

// the function that will be called for the title() manipulator

ostream& makeTitle(ostream& os, charptr string)
{
return os << "Dr. " << string << " (PhD)";
}

// get a declaration for charptr (we can't simply use char *
// because the space in that type name would confuse the
// macro pasting.)

IOMANIPdeclare(charptr);

OMANIP(charptr) title(charptr string)
{
return OMANIP(charptr) (makeTitle, string);
}

// if the manipulator doesn't take any parameters, we don't
// need to pass anything back to a separate function, so it's
// a good deal simpler.

ostream& greet(ostream &os)
{
return os << "Good Day, ";
}

int main()
{
cout << greet << title("Doolittle") ;
return 0;
}















PRODUCT : Borland C++ NUMBER : 1544
VERSION : All
OS : All
DATE : July 19, 1993 PAGE : 2/2

TITLE : Creating an ostream manipulator




DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.















































  3 Responses to “Category : C++ Source Code
Archive   : TI1544.ZIP
Filename : TI1544.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/