Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class forma_geo
- {
- protected:
- int baza, inaltimea;
- public:
- void set_baza(int b);
- void set_inaltime(int h);
- };
- void forma_geo:: set_baza(int b){
- baza = b;
- }
- void forma_geo:: set_inaltime(int h){
- inaltimea = h;
- }
- class cost
- {
- public:
- float calcul(float aria)
- {
- return (aria * 180 );
- }
- };
- class triunghi: public forma_geo, public cost
- {
- public:
- float get_aria()
- {
- return(baza * inaltimea / 2);
- }
- };
- int main ()
- { triunghi c1;
- int b, h;
- cout <<"Introduce ti baza: "; cin >> b;
- cout <<"Introduce ti inaltime: "; cin >> h ;
- c1.set_baza(b);
- c1.set_inaltime(h);
- cout<<"\nAria formei geometrice este "<<c1.get_aria()<<endl;
- cout<<"Costul total este "<<c1.calcul(c1.get_aria())<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement