Syntax for creating user defined manipulators in C++
C++ provides a set of predefined manipulators. The header file iomanip.h header file contains these manipulators. Moreover, you can design your own manipulators in C++ to suit specific purpose. The user defined manipulators are defined as follows:
ostream & manipulator(ostream & ostr)
set of statements;
Consider the following example which creates a user defined manipulator named curr for displaying Rs. and sets the precision to 2.
ostream & curr(ostream & ostr)
float amt = 4.5476;
//Output: Rs. 4.55