I am trying to load the vector of strings "Names" which is a private data member for the class "BagOfNames" from the istream using cin. However, I am having trouble with the syntax to do so in the "void input_names ()" function. Can someone please help? Thank you.


Code:
#include <fstream>
#include <iostream>
#include <vector>
#include <string>

using namespace std ;

class BagOfNames
{
  public:
   void input_names(istream& name_p);
   // assumes that an ifstream object is already opened (or cin) 
   // is used as an argument for inStream_p

   void output_names(ostream& outStream_p);
   // assumes that an ofstream object is already opened (or cout) 
   // is used as an argument for outStream_p

   void erase_name(string aName_p);
   void add_name(string aName_p);
   string get_random_name();
   string get_longest_name();
   void delete_duplicates();
   vector <string> get_duplicates();


  private:
   vector <string> Names ;

}; 

int main ()
{
  
  BagOfNames Students ;
  
  fstream Name_Stream ;
  string user_response ;
  
  cout << "Would you like to enter information from the keyboard?" 
       << "(Type 'yes' or 'no'): " << endl ;
  cin >> user_response ;
  
  if (user_response == "yes" )
   {
    cout << "Enter Names, one per line and use 'Ctrl Z' to end Input:" ;
    Students . input_names (cin) ;        
   } 
  else
   {
    Name_Stream . open ("E:\\CSCI 135\\Files\\Names.txt") ;
    Students . input_names (Name_Stream) ;
   } 
    
system ("Pause") ;
return 0 ;
}

void BagOfNames :: input_names(istream& name_p) 
{
 Names . push_back (cin) ;
}