Advertisement
100rads

studenti sa indeksom

Apr 12th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. class Student {
  8.     string ime;
  9.     string prezime;
  10.     string indeks;
  11.  
  12.     static int br;
  13. public:
  14.     Student() {
  15.         br++;
  16.         indeks = to_string(br) + "-2019";
  17.     }
  18.  
  19.     void setDetails() {
  20.         cout << "Unesite ime: ";
  21.         cin >> ime;
  22.         cout << "Unesite prezime: ";
  23.         cin >> prezime;
  24.     }
  25.  
  26.     void printDetails()
  27.     {
  28.         cout << ime << " " << prezime << " " << indeks << endl;
  29.     }
  30.  
  31. }studenti[10];
  32. int Student::br = 0;
  33.  
  34. int main()
  35. {
  36.     int unos;
  37.     int i;
  38.  
  39.     cout << "Koliko studenata zelite upisati? (MAX: 10)" << endl;
  40.     cin >> unos;
  41.  
  42.     for (i = 0; i < unos; i++)
  43.     {
  44.         studenti[i].setDetails();
  45.     }
  46.  
  47.     for (i = 0; i < unos; i++)
  48.     {
  49.         studenti[i].printDetails();
  50.     }
  51.  
  52.  
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement