Advertisement
Guest User

Untitled

a guest
May 24th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class A
  4. {
  5. protected:
  6. int x;
  7.  
  8. public:
  9. void setx();
  10. void sqr();
  11. };
  12.  
  13. class B:public A
  14. {
  15. private:
  16. int y;
  17.  
  18. public:
  19. void sety();
  20. void cube();
  21. };
  22.  
  23. void A::setx()
  24. {
  25.  
  26. cin>>x;
  27.  
  28. }
  29.  
  30. void A::sqr()
  31. {
  32. cout<<"Square is:"<<x*x;
  33. }
  34.  
  35. void B::sety()
  36. {
  37.  
  38. cin>>y;
  39. }
  40.  
  41. void B::cube()
  42. {
  43. cout<<"Cube is:"<<y*y*y;
  44. }
  45. int main() {
  46.  
  47.  
  48. B b;
  49. b.setx();
  50. b.sety();
  51. b.sqr();
  52. b.cube();
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement