fork download
  1. #include <iostream>
  2. struct A {
  3. bool f(A* a) { std::cout << "true "; return true; }
  4. };
  5. struct B : A {
  6. bool f(B* b) { std::cout << "false "; return false; }
  7. };
  8. int main() {
  9. A* a = new A();
  10. A* ab = new B();
  11. B* b = new B();
  12. a->f(a); a->f(ab); a->f(b); // true, true, true
  13. std::cout << std::endl;
  14. ab->f(a); ab->f(ab); ab->f(b); // true, true, true
  15. std::cout << std::endl;
  16. b->A::f(a); b->A::f(ab); b->f(b); // true true false
  17. std::cout << std::endl;
  18. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
true true true 
true true true 
true true false