fork(1) download
  1. #include <iostream>
  2.  
  3. class Interface
  4. {
  5. public:
  6. virtual ~Interface() {}
  7. virtual void myIfMethod() = 0;
  8. };
  9.  
  10. class Derived : public Interface
  11. {
  12. private:
  13. void myIfMethod(){std::cout << "private method invoked via public interface" << std::endl;}
  14. };
  15.  
  16. int main()
  17. {
  18. Interface* myObj = new Derived;
  19. myObj->myIfMethod();
  20. delete myObj;
  21. return 0;
  22. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
private method invoked via public interface