fork download
  1. #include <iostream>
  2.  
  3. struct foo {
  4. void operator<<(int) {
  5. std::cout << "foo int\n";
  6. }
  7. void operator<<(char) {
  8. std::cout << "foo char\n";
  9. }
  10. };
  11.  
  12. struct bar : foo {
  13. void operator<<(char) {
  14. std::cout << "bar char\n";
  15. }
  16. };
  17.  
  18. int main() {
  19. foo f;
  20. f << 1;
  21. f << 'c';
  22.  
  23. bar b;
  24. b << 1;
  25. b << 'c';
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
foo int
foo char
bar char
bar char