fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct A {
  6. int f() { return 42; }
  7. };
  8.  
  9. struct B : A {
  10. using A::f; // <- This is the magic line!
  11. int f(int n) { return 42 + n; }
  12. };
  13.  
  14. int main() {
  15. B b;
  16. cout << b.f() << endl;
  17. cout << b.f(100) << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 4404KB
stdin
Standard input is empty
stdout
42
142