Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Student.h
- #include <vector>
- using namespace std;
- class Student {
- private:
- char ime[30];
- char prezime[30];
- int brindex;
- int maxispit;
- int brpolozenih;
- vector<int> ocene;
- public:
- void Student::ucitajStudenta();
- void Student::pokaziStudenta();
- Student::Student();
- int Student::brIndex() {
- return brindex;
- }
- int Student::brPolozenih() {
- return brpolozenih;
- }
- void Student::dodajOcenu(int x);
- };
- // Student.cpp
- #include <iostream>
- #include <vector>
- #include "Student.h"
- using namespace std;
- Student::Student() {
- maxispit = 30;
- ocene.resize(maxispit);
- }
- void Student::ucitajStudenta() {
- cout << "Upisite ime a zatim i prezime studenta \n";
- cin >> ime;
- cin >> prezime;
- cout << "Broj indeksa: \n";
- cin >> brindex;
- cout << "Broj polozenih ispita : \n";
- cin >> brpolozenih;
- cout << "Ocene: \n";
- for (int i = 0; i < brpolozenih; i++) {
- cin >> ocene[i];
- }
- }
- void Student::pokaziStudenta() {
- cout << brindex << " " << ime << " " << prezime << endl;
- for (int i = 0; i < brpolozenih; i++) {
- cout << ocene[i] << " ";
- }
- }
- void Student::dodajOcenu(int x) {
- ocene[brpolozenih] = x;
- brpolozenih++;
- }
- // main.cpp
- #include "Student.h"
- using namespace std;
- void main() {
- Student s;
- s.ucitajStudenta();
- s.dodajOcenu(8);
- s.pokaziStudenta();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement