Advertisement
a3f

Counting std:cout

a3f
May 8th, 2014
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. // should be well-defined behaviour
  2. #include <iostream>
  3. int strings_printed = 0;
  4. std::ostream& operator << (std::ostream& out, const char* str){
  5.     strings_printed++;
  6.  
  7.     out << std::string(str);
  8.     return out;
  9. }
  10. int main ()
  11. {
  12.     std::cout << "LOL";
  13.     std::cout << "LOL";
  14.     std::cout << "LOL";
  15.     std::cout << "LOL";
  16.     std::cout << 2;
  17.  
  18.     std::cout <<  std::endl << strings_printed << " strings were printed";
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement