fork download
  1.  
  2. #include<iostream>
  3. using namespace std;
  4. class Base
  5. {
  6. int x, y;
  7. public:
  8. Base(int xx = 10, int yy = 10)
  9. {
  10. x = xx;
  11. y = yy;
  12. }
  13. void Show()
  14. {
  15. cout<< x * y << endl;
  16. }
  17. };
  18. class Derived : public Base
  19. {
  20. private:
  21. Base objBase;
  22. public:
  23. Derived(int xx, int yy) : Base(xx, yy), objBase(yy, yy)
  24. {
  25. objBase.Show();
  26. }
  27. };
  28. int main()
  29. {
  30. Derived objDev(10, 20);
  31. return 0;
  32. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
400