Advertisement
Alx09

Untitled

May 27th, 2020
1,427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. class forma_geo
  6. {
  7. protected:
  8.     int baza, inaltimea;
  9.  
  10.  
  11. public:
  12.     void set_baza(int b);
  13.     void set_inaltime(int h);
  14.  
  15.  
  16. };
  17. void forma_geo:: set_baza(int b){
  18.     baza = b;
  19. }
  20. void forma_geo:: set_inaltime(int h){
  21.     inaltimea = h;
  22. }
  23. class cost
  24. {
  25. public:
  26.     float calcul(float aria)
  27.     {
  28.         return (aria  * 180 );
  29.     }
  30. };
  31.  
  32. class triunghi: public forma_geo, public cost
  33. {
  34. public:
  35.     float get_aria()
  36.     {
  37.         return(baza * inaltimea / 2);
  38.     }
  39. };
  40.  
  41. int main ()
  42. { triunghi c1;
  43.  int b, h;
  44.   cout <<"Introduce ti baza: "; cin >> b;
  45.   cout <<"Introduce ti inaltime: "; cin >> h ;
  46.   c1.set_baza(b);
  47.   c1.set_inaltime(h);
  48. cout<<"\nAria formei geometrice este "<<c1.get_aria()<<endl;
  49. cout<<"Costul total este "<<c1.calcul(c1.get_aria())<<endl;
  50.  
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement