Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. using namespace std;
  4. class Shape
  5. {
  6. public:
  7. double length,breadth,height,base;
  8. void get_data()
  9. {
  10. //double length,breadth,height,base;
  11. cout<<"Enter the length of the Rectangle: ";
  12. cin>>length;
  13. cout<<"Enter the breadth of the Rectangle: ";
  14. cin>>breadth;
  15.  
  16.  
  17. cout<<"Enter the height of the Triangle: ";
  18. cin>>height;
  19. cout<<"Enter the base of the Triangle: ";
  20. cin>>base;
  21.  
  22. }
  23. };
  24. class Rectangle : public Shape
  25. {
  26. public:
  27. void area_of_rac()
  28. {
  29. double area = length*breadth;
  30. cout<<"The Rectangle area: "<<area<<endl;
  31. }
  32. };
  33. class Triangle : public Shape
  34. {
  35. public:
  36. void area_of_tri()
  37. {
  38. double area = 0.5*height*base;
  39. cout<<"The Triangle area: "<<area<<endl;
  40. }
  41. };
  42. int main()
  43. {
  44. Shape obj;
  45. obj.get_data();
  46. Rectangle obj1;
  47. obj1.area_of_rac();
  48. Triangle obj2;
  49. obj2.area_of_tri();
  50.  
  51. getch();
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement