so I'm struggling with these things:
I have method that returns istream input and takes istream input as a parameter, sends values to vector and stores them in it. Now, when I've entered 1 value, I'm trying to make a check if vector already contains that value, here is my code to understand it better:
struct Predmet {
string naziv;
string odsjek;
istream& dodaj_predmet(istream &);
};
struct Student {
string brojIndeksa;
string ime;
string prezime;
map<std::string, int> ocjene;
istream& dodaj_studenta(istream &);
};
vector<Student> studenti;
vector<Predmet> predmeti;
Student s;
Predmet p;
istream& Student::dodaj_studenta(istream & input){
cout << "### Unesite podatke o studentu: " << endl;
cout << endl;
cout << "Unesite broj indeksa studenta: " << endl;
getline(input, brojIndeksa);
cout << endl;
cout << "Unesite ime studenta: " << endl;
getline(input, ime);
cout << endl;
cout << "Unesite prezime studenta: " << endl;
getline(input, prezime);
cout << endl;
cout << "*** Uspjesno ste unijeli studenta ***" << endl;
return input;
}
So I'm trying to make a check if value entered for structure member brojIndeksa
already exists in vector, and I'm not sure how to do it.
Also how can I add values to map, because I need to add pair<string, int>, and not sure how, because I need to check if STRING
is a member of predmeti
vector?
Thanks.
Aucun commentaire:
Enregistrer un commentaire