fork download
  1. #include <iostream>
  2.  
  3. class A
  4. {
  5. public:
  6. virtual ~A() {}
  7. void print()
  8. {
  9. print_impl();
  10. }
  11. private:
  12. virtual void print_impl() = 0;
  13. };
  14.  
  15. class B : public A
  16. {
  17. void print_impl() { std::cout << "B" << std::endl; }
  18. };
  19.  
  20. int main()
  21. {
  22. A* b = new B();
  23. b->print();
  24. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
B