Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.40 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Forma
  6. {
  7. protected:
  8.     int brStrani;
  9. public:
  10.     Forma(int brStrani=0)
  11.     {
  12.         this->brStrani=brStrani;
  13.     }
  14. };
  15.  
  16. class Kvadrat:public Forma
  17. {
  18. protected:
  19.     int a;
  20. public:
  21.     Kvadrat(int brStrani=0, int a=0):Forma(brStrani)
  22.     {
  23.         this->a=a;
  24.     }
  25.  
  26.     void pecati()
  27.     {
  28.         cout<<"Broj strani: "<<brStrani<<endl;
  29.         cout<<"Strana a: "<<a<<endl;
  30.     }
  31. };
  32.  
  33. class Triagolnik:public Forma
  34. {
  35. protected:
  36.     int a;
  37.     int b;
  38.     int c;
  39. public:
  40.     Triagolnik(int brStrani=0, int a=0, int b=0, int c=0):Forma(brStrani)
  41.     {
  42.         this->a=a;
  43.         this->b=b;
  44.         this->c=c;
  45.     }
  46.  
  47.     void pecati()
  48.     {
  49.         cout<<"Broj strani: "<<brStrani<<endl;
  50.         cout<<"Strana a: "<<a<<endl;
  51.         cout<<"Strana b: "<<b<<endl;
  52.         cout<<"Strana c: "<<c<<endl;
  53.     }
  54. };
  55.  
  56. class Pravoagolnik:public Forma
  57. {
  58. protected:
  59.     int a;
  60.     int b;
  61. public:
  62.     Pravoagolnik(int brStrani=0, int a=0, int b=0):Forma(brStrani)
  63.     {
  64.         this->a=a;
  65.         this->b=b;
  66.     }
  67.     void pecati()
  68.     {
  69.         cout<<"Broj strani: "<<brStrani<<endl;
  70.         cout<<"Strana a: "<<a<<endl;
  71.         cout<<"Strana b: "<<b<<endl;
  72.     }
  73. };
  74. int main()
  75. {
  76.     Kvadrat k(1,5);
  77.     k.pecati();
  78.     Triagolnik t(3,3,4,5);
  79.     t.pecati();
  80.     Pravoagolnik p(2,10,20);
  81.     p.pecati();
  82.  
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement