fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class a
  5. {
  6.  
  7.  
  8. public:
  9. a(void)
  10. {
  11. cout<<"a defaut ctor"<<endl;
  12. }
  13. a(int i)
  14. {
  15. cout<<"a custom ctor "<<i<<endl;
  16. }
  17. };
  18. class b : public a
  19. {
  20. public:
  21. b(void)
  22. {
  23. cout<<"b defaut ctor"<<endl;
  24. }
  25. b(int i) : a(i)
  26. {
  27. cout<<"b custom ctor "<<i<<endl;
  28. }
  29. };
  30.  
  31. int main()
  32. {
  33. b B1;
  34. b B2(5);
  35.  
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
a defaut ctor
b defaut ctor
a custom ctor 5
b custom ctor 5