Hello,
I know that to format output I can use a number of predefined manipulators such as std::boolalpha, std::hex, etc. and use them such as:
and that would print false.Code:int myNumber = 0; cout << boolalpha << myNumber << endl;
I would like to write my own manipulators to format a couple of things that cannot be done with the usual ones, however I've been unable to locate info about how to do this.
In particular I would like to be able to store in a text file certain words and map them to bool values in the program, for example
should print "Yeah!!", and the other way around: I would like to read "Yeah!!" from a string and store it as a boolCode:bool dropTheBomb = true; cout << my_manipulator << dropTheBomb << endl;
Does anybody know how to do this?



LinkBack URL
About LinkBacks


