im trying to do creating objects in a one condition and listing this objects in another condition, but it doesn't work.Its like that.
void fillVector(vector<Account>& newcreateAccObj){
string name;
string password;
cout<<"Enter your surname:"<<endl;
cin>>name;
cout<<"Enter your password:"<<endl;
cin>>password;
Account newAcc(name,password);
newcreateAccObj.push_back(newAcc);
cout<<endl;
}
-----this works fine.-----
void printVector(vector& newcreateAccObj){
unsigned int size=newcreateAccObj.size();
for(unsigned int i=0;i<size;i++){
cout<<"Account"<<i+1<<endl;
cout<<"-----------"<<endl;
newcreateAccObj[i].getId();
newcreateAccObj[i].getName();
cout<<endl;
}
}
--this works fine too when i execute these 2 functions in same condition.--
--but when i do this--
if(input=="1"){
fillVector(createAccObj);
}
else if(input=="2"){
printVector(createAccObj);
}
I choose option 1 first.I create my object and returning the select menu, after that i choose option 2 and it gives me a blank output.
THX FOR HELP.
Aucun commentaire:
Enregistrer un commentaire