SHARE
TWEET

Untitled

a guest Dec 9th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class Avion
  5. {
  6.     private:
  7.         int *brPutnika;
  8.     public:
  9.             Avion()
  10.             {
  11.                 brPutnika= new int;
  12.             }
  13.  
  14.         void setBrPutnika(int b)
  15.         {
  16.             *(this->brPutnika)=b;
  17.         }
  18.         int getBrPutnika()
  19.         {
  20.             return *(this->brPutnika);
  21.         }
  22.  
  23.         ~Avion()
  24.         {
  25.             delete this->brPutnika;
  26.         }
  27.         };
  28.  
  29. int main()
  30. {
  31.     int brAviona;
  32.  
  33.     cout<<"Unesite broj aviona"<<endl;
  34.     cin>>brAviona;
  35.  
  36.     Avion novo[brAviona];
  37.     for (int i=0; i<brAviona;i++)
  38.     {
  39.         int j;
  40.         cout<<"Broj putnika: ";
  41.         cin>>j;
  42.         novo[i].setBrPutnika(j);
  43.     }
  44.  
  45.     int j=0;
  46.  
  47.     for (int i=0;i<brAviona;i++)
  48.     {
  49.         j+=novo[i].getBrPutnika();
  50.  
  51.     }
  52.  
  53.     cout<<"Ukupan broj putnika: "<<j;
  54.  
  55.  
  56.  
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top