Advertisement
Imran1107048

Multi Level Inheritance for Square & Cube

Apr 19th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class square
  5. {
  6. public:
  7. int a=3;
  8. square()
  9. {
  10. a=a*a;
  11. cout << "Square is: " << a << endl;
  12. }
  13. };
  14.  
  15. class cube : public square
  16. {
  17. public:
  18. int a=3;
  19.  
  20.  
  21. cube()
  22. {
  23. a=a*a*a;
  24. cout << "Cube is: " << a << endl;
  25. }
  26. };
  27.  
  28. class number : public cube
  29. {
  30.  
  31. };
  32.  
  33. int main()
  34. {
  35. number obj;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement