fork download
  1. #include <iostream>
  2. #include <memory>
  3. using namespace std;
  4.  
  5. struct Interface {
  6. virtual void f () = 0;
  7. virtual ~Interface() {};
  8. };
  9.  
  10. struct SomeClass {
  11. virtual void additionalBehaviour () = 0;
  12. void g () {
  13. additionalBehaviour ();
  14. /*Some stuff with printing into a ostringstream*/
  15. }
  16. };
  17.  
  18. struct Derived : public SomeClass, public Interface {
  19. void additionalBehaviour () override { cout<<"additional"<<endl; /*Some printing to oss*/ }
  20. void f () override { g (); }
  21. };
  22.  
  23. int main () {
  24. unique_ptr<Interface> ifc (new Derived ());
  25. ifc->f ();
  26. cout << "HI!" << endl;
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
additional
HI!