fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base
  5. {
  6. public:
  7. Base()
  8. {
  9. cout << "Base()\n";
  10. }
  11.  
  12. Base(int)
  13. {
  14. cout << "Base(int)\n";
  15. }
  16.  
  17. ~Base()
  18. {
  19. cout << "~Base()\n";
  20. }
  21.  
  22. Base& operator=(int)
  23. {
  24. cout << "Base::operator=(int)\n";
  25. return *this;
  26. }
  27. };
  28.  
  29. class Derived : public Base
  30. {
  31. public:
  32. using Base::operator=;
  33.  
  34. Derived()
  35. {
  36. cout << "Derived()\n";
  37. }
  38.  
  39. Derived(int n) : Base(n)
  40. {
  41. cout << "Derived(int)\n";
  42. }
  43.  
  44. ~Derived()
  45. {
  46. cout << "~Derived()\n";
  47. }
  48. };
  49.  
  50. class Holder
  51. {
  52. public:
  53. Holder(int n)
  54. {
  55. member = n;
  56. }
  57.  
  58. Derived member;
  59. };
  60.  
  61. int main(int argc, char* argv[])
  62. {
  63. cout << "Start\n";
  64. Holder obj(1);
  65. cout << "Finish\n";
  66.  
  67. return 0;
  68. }
Success #stdin #stdout 0.01s 2680KB
stdin
Standard input is empty
stdout
Start
Base()
Derived()
Base::operator=(int)
Finish
~Derived()
~Base()