Advertisement
ithoran

V1 Z02 C++

Nov 17th, 2015
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. // Student.h
  2. #include <vector>
  3. using namespace std;
  4. class Student {
  5. private:
  6.     char ime[30];
  7.     char prezime[30];
  8.     int brindex;
  9.     int maxispit;
  10.     int brpolozenih;
  11.     vector<int> ocene;
  12. public:
  13.     void Student::ucitajStudenta();
  14.     void Student::pokaziStudenta();
  15.     Student::Student();
  16.     int Student::brIndex() {
  17.         return brindex;
  18.     }
  19.     int Student::brPolozenih() {
  20.         return brpolozenih;
  21.     }
  22.     void Student::dodajOcenu(int x);
  23. };
  24.  
  25. // Student.cpp
  26. #include <iostream>
  27. #include <vector>
  28. #include "Student.h"
  29. using namespace std;
  30. Student::Student() {
  31.     maxispit = 30;
  32.     ocene.resize(maxispit);
  33. }
  34. void Student::ucitajStudenta() {
  35.     cout << "Upisite ime a zatim i prezime studenta \n";
  36.     cin >> ime;
  37.     cin >> prezime;
  38.     cout << "Broj indeksa: \n";
  39.     cin >> brindex;
  40.     cout << "Broj polozenih ispita : \n";
  41.     cin >> brpolozenih;
  42.     cout << "Ocene: \n";
  43.     for (int i = 0; i < brpolozenih; i++) {
  44.         cin >> ocene[i];
  45.     }
  46. }
  47. void Student::pokaziStudenta() {
  48.     cout << brindex << " " << ime << " " << prezime << endl;
  49.     for (int i = 0; i < brpolozenih; i++) {
  50.         cout << ocene[i] << " ";
  51.     }
  52. }
  53. void Student::dodajOcenu(int x) {
  54.     ocene[brpolozenih] = x;
  55.     brpolozenih++;
  56. }
  57.  
  58. // main.cpp
  59. #include "Student.h"
  60. using namespace std;
  61. void main() {
  62.     Student s;
  63.     s.ucitajStudenta();
  64.     s.dodajOcenu(8);
  65.     s.pokaziStudenta();
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement