fork(2) download
  1. #include <iostream>
  2.  
  3. class Foo {
  4. public:
  5. virtual void bar(void*) { std::cout << "Called: bar(void*)" << std::endl; }
  6. virtual void bar(Foo*) { std::cout << "Called: bar(Foo*)" << std::endl; }
  7.  
  8. virtual ~Foo() = default;
  9. };
  10.  
  11. class FooTwo : public Foo {};
  12.  
  13. int main() {
  14. Foo foo;
  15. FooTwo footwo;
  16.  
  17. foo.bar(&foo);
  18. foo.bar(&footwo);
  19.  
  20. footwo.bar(&foo);
  21. footwo.bar(&footwo);
  22. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
Called: bar(Foo*)
Called: bar(Foo*)
Called: bar(Foo*)
Called: bar(Foo*)