I have this class :
int br=0; // br is counter how much records i hold in my vector
class racunalo{
public:
void upis(string naziv, string velicinaRam, string velicinaHDD, string brzina, string proizvodac);
void upisKomp();
string getNaziv(int s) const;
void pregled();
void upisDat();
void pregledNaziv();
void pregledProizvodac();
void brisanjeRac();
string getVelicinaRam(int s) const;
string getVelicinaHDD(int s) const;
string getVelicinaBrzina(int s) const;
string getProizvodac(int s) const;
string getBrzina(int s) const;
void ispisKomp();
private:
struct komp{
string naziv;
string velicinaRam;
string velicinaHDD;
string brzina;
string proizvodac;
};
vector<komp>racunala;
};
and i want to delete record from vector racunala
i tried to write function like this:
void racunalo::brisanjeRac(){
cout<<"Enter computer name you want to delete:"<<endl;
string comp_name;
cin>>comp_name;
for(int i=0;i<br;i++){
if(kompjuteri.getNaziv(i) == comp_name){
racunala.erase(racunala.begin()+i);}
}}
but it doesnt work. Lets say i got 2 records in my file.
Acer
Toshiba
when i try to delete Acer it doesn't delete but it get replaced by Toshiba so i get output like
Toshiba
Toshiba
Please help me, thank you in advance.