How to overload "cout <<" to print anything?

Правка en1, от royappa, 2020-06-16 20:54:49

I seem to remember, but cannot find, a tutorial posted here on how to use new features in C++ to print things more easily from cout.

It showed how to set it up so you can do "cout << x" on several common data structures (vectors, pairs, maps, etc.) and it would print them, e.g., a vector may print out as "32 12 45\n". Of course you would have to implement some code for each datatype you want.

If someone remembers this tutorial or can show how, I would appreciate greatly. Thanks!

Теги c++, cout

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский royappa 2020-06-16 20:54:49 538 Initial revision (published)