fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class base {
  5. public:
  6. base();
  7. base(const base& orig);
  8. virtual ~base();
  9. void baseMethod(int);
  10.  
  11. private:
  12. };
  13.  
  14. base::base()
  15. {
  16. }
  17.  
  18. base::~base() {
  19. }
  20.  
  21. void base::baseMethod(int a)
  22. {
  23. std::cout<<"base::baseMethod : "<<a<<std::endl;
  24. }
  25.  
  26. class derivative : public base{
  27. public:
  28. derivative();
  29. derivative(const derivative& orig);
  30. virtual ~derivative();
  31.  
  32. void derivativeMethod(int);
  33. void baseMethod(int);
  34. private:
  35.  
  36. };
  37.  
  38. derivative::derivative() : base(){
  39. }
  40.  
  41. derivative::~derivative() {
  42. }
  43.  
  44. void derivative::baseMethod(int a)
  45. {
  46. std::cout<<"derivative::baseMethod : "<<a<<std::endl;
  47. }
  48.  
  49. void derivative::derivativeMethod(int a)
  50. {
  51. baseMethod(a);
  52. derivative::baseMethod(a);
  53. }
  54.  
  55. int main()
  56. {
  57. derivative t;
  58. t.baseMethod(1);
  59. t.derivativeMethod(2);
  60. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
derivative::baseMethod : 1
derivative::baseMethod : 2
derivative::baseMethod : 2