Custom cout output manipulator : cout custom « Console « C++






Custom cout output manipulator

Custom cout output manipulator

#include <iostream>
using namespace std;

// Attention:
ostream &atn(ostream &stream)
{
  stream << "Attention: ";
  return stream;
}

// Please note:
ostream &note(ostream &stream)
{
  stream << "Please Note: ";
  return stream;
}

int main()
{
  cout << atn << "High voltage circuit\n";
  cout << note << "Turn off all lights\n";

  return 0;
}


           
       








Related examples in the same category

1.Create an output manipulator. Create an output manipulator.
2.A manipulator: turns on the showbase flag and sets output to hexadecimal
3.A simple output manipulator: sethexA simple output manipulator: sethex
4.Define operator for coutDefine operator for cout
5.Create custom output formatCreate custom output format