title: Read text file into class member variables using getline - c++
body: <p>I recently started learning c++ so I'm still learning. Basically I'm trying to read my text file when the string "NEW_EMPLOYEE" is found and then store every line into their respective member variables until an empty line is found in the text file to stop. The problem I'm having is how can I use getline to import each line into each variable of my class "Employee" all at once? Should I use istringstream instead?</p>
  
  <p>My text file called "employee.txt"</p>
  
  <pre><code>NEW_EMPLOYEE
  460713
  John
  Smith
  64000
  36
  
  END_OF_FILE
  </code></pre>
  
  <p>My class Employee:</p>
  
  <pre><code>class Employee {
  
  private: //Member variables
  int ID;
  string FirstName;
  string LastName;
  int Salary;
  int Hours;
  
  public:
  Employee() {} //Default constructor
  Employee(int&amp; id, string&amp; firstName, string&amp; lastName, int&amp; salary, int&amp; hours) {
      ID = id;
      FirstName = firstName;
      LastName = lastName;
      Salary = salary
      Hours = hours;
      }
  };
  </code></pre>
  
  <p>My main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  
  int main() {  
      Employee employee;
      int id;
      string firstName;
      string lastName;
      int salary;
      int hours;
      string line;
  
      ifstream employeeFile;
      employeeFile.open("employee.txt");
  
      while(getline(employeeFile, line)) {
          if(line == "NEW_EMPLOYEE") {
              do {
                  //Don't know what to do here???
              } while (!line.empty());
          }
      }
      employeeFile.close();
      return 0;
  }
  </code></pre>