fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Base {
  5. virtual void a() = 0;
  6. virtual void b() = 0;
  7. };
  8.  
  9. struct Impl {
  10. void a() {
  11. std::cout << "a()" << std::endl;
  12. }
  13. void b() {
  14. std::cout << "b()" << std::endl;
  15. }
  16. };
  17.  
  18. struct Derived : Base, Impl {
  19. void a(){Impl::a();}
  20. void b(){Impl::b();}
  21. };
  22.  
  23. void foo(Base&& b) {
  24. b.a();
  25. b.b();
  26. }
  27.  
  28. int main() {
  29. foo(Derived{});
  30. return 0;
  31. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
a()
b()