Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Forma
- {
- protected:
- int brStrani;
- public:
- Forma(int brStrani=0)
- {
- this->brStrani=brStrani;
- }
- };
- class Kvadrat:public Forma
- {
- protected:
- int a;
- public:
- Kvadrat(int brStrani=0, int a=0):Forma(brStrani)
- {
- this->a=a;
- }
- void pecati()
- {
- cout<<"Broj strani: "<<brStrani<<endl;
- cout<<"Strana a: "<<a<<endl;
- }
- };
- class Triagolnik:public Forma
- {
- protected:
- int a;
- int b;
- int c;
- public:
- Triagolnik(int brStrani=0, int a=0, int b=0, int c=0):Forma(brStrani)
- {
- this->a=a;
- this->b=b;
- this->c=c;
- }
- void pecati()
- {
- cout<<"Broj strani: "<<brStrani<<endl;
- cout<<"Strana a: "<<a<<endl;
- cout<<"Strana b: "<<b<<endl;
- cout<<"Strana c: "<<c<<endl;
- }
- };
- class Pravoagolnik:public Forma
- {
- protected:
- int a;
- int b;
- public:
- Pravoagolnik(int brStrani=0, int a=0, int b=0):Forma(brStrani)
- {
- this->a=a;
- this->b=b;
- }
- void pecati()
- {
- cout<<"Broj strani: "<<brStrani<<endl;
- cout<<"Strana a: "<<a<<endl;
- cout<<"Strana b: "<<b<<endl;
- }
- };
- int main()
- {
- Kvadrat k(1,5);
- k.pecati();
- Triagolnik t(3,3,4,5);
- t.pecati();
- Pravoagolnik p(2,10,20);
- p.pecati();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement