I am sure that all of your suggestions work(and I am very grateful for your help), however, we have not covered them in class ( namely getline and back_inserter) so there has to be a way to do this using only the class and vector.
In class the professor put :
Code:
if (user_response == "yes" )
{
cout << "Enter Names, one per line and use 'Ctrl Z' to end Input:" ;
Students . input_names (cin) ;
}
When that block was executed, he was able to input multiple names in the cin stream and end it with ctrl z . but I did not catch how he implemented it within the input_names () function. And I know that he did not use an accessor fuction to get the cin stream into the input_names () function. That is why I think the parameter placeholder is there:
Code:
void BagOfNames :: input_names(istream& name_p)
{
Names . push_back (cin) ;
}
So by doing the following:
Code:
Students . input_names (cin) ;
I thought that the cin stream would take the place of the parameter placeholder and when I loaded the vector it would do just that:
Code:
void BagOfNames :: input_names(istream& name_p)
{
Names . push_back (cin) ;
}
Instead I got a syntax error I cannot fix even if I use the placeholder name_p instead of cin.