title: C++ Extraction Operator for Class Functions
body: <p>I'm not sure if  operator overloading is what I'm looking for, but I need to know the best way to achieve the following in C++;</p>
  
  <p>I have a class Employee (for simplicity) with just an ID number atm. Please assume the input file has an int number and some characters after (1 line shown only), such as: </p>
  
  <p>1234 Charles Hammond  </p>
  
  <p>Here is the code so far. I am trying to use the extraction operator to get the integer and other data from input file to my class function (SetID);</p>
  
  <pre><code>class Employee
  {
      int employeeID;
  
  public:
       void SetID(int);
  }
  
  void Employee::SetID(int empID)
  {
      employeeID = empID;
  }
  
  int main(void)
  {
      int lineCounter = 4;
      Employee emp;
  
      //Create filestream objects and open
      ifstream input;
      ofstream output;
      input.open("input.txt");
      output.open("output.txt");
  
  
      for (int i = 0; i &lt; lineCounter; i++)
      {
          input &gt;&gt; emp.SetID(input.get()); //illegal? Best way to do this
      }
  
  
      //Close program
      output.close();
      input.close();
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>I am simply trying to get the ID from the input file and store it in the class member "employeeID" to be used for calculations later. </p>