fork download
  1. #include <iostream>
  2.  
  3. class base {
  4. virtual void time_impl()=0;
  5. public:
  6. void time() {
  7. //Default behaviour
  8. std::cout << "Hello ";
  9. //Call overridden behaviour
  10. time_impl();
  11. }
  12. };
  13.  
  14. class child : public base {
  15. void time_impl() {
  16. std::cout << "world\n";
  17. }
  18. };
  19.  
  20. int main () {
  21. child c;
  22. c.time();
  23. }
Success #stdin #stdout 0s 2884KB
stdin
Standard input is empty
stdout
Hello world