fork(5) download
  1. #include <iostream>
  2.  
  3. class Parent
  4. {
  5. private:
  6. int variable;
  7. public:
  8. virtual void firstfunction();
  9. virtual void secondfunction();
  10. void nonvirtualfunction();
  11.  
  12. void print_variable()
  13. {
  14. std::cout << variable << std::endl;
  15. }
  16. };
  17.  
  18. void Parent::nonvirtualfunction()
  19. {
  20. variable = 5;
  21. }
  22.  
  23. class Child : public Parent
  24. {
  25. public:
  26. void firstfunction();
  27. void secondfunction();
  28. };
  29.  
  30. void Child::secondfunction()
  31. {
  32. Parent::nonvirtualfunction();
  33. }
  34.  
  35. int main()
  36. {
  37. Child c;
  38. c.secondfunction();
  39. c.print_variable();
  40. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
5