title: Queue not adding objects - C++ 11
body: <p>I have two custom classes, <code>Passenger</code> and <code>Elevator</code> contained in the <strong><code>Passenger.h</code></strong> header file:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;queue&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  class Passenger
  {
      public:
  
      explicit Passenger(int startTime, int startFloor, int endFloor, int waitTime){
          this-&gt;startTime = startTime;
          this-&gt;startFloor = startFloor;    
          this-&gt;endFloor = endFloor;
          this-&gt;waitTime = waitTime;
      }//end constructor
  
      void increaseWait(int increase){
          this-&gt;waitTime += increase;
      }
  
      int getWait(){
          return this-&gt;waitTime;
      }
  
      int startTime, startFloor, endFloor, waitTime;
  
  }; //end passenger
  
  
  class Elevator
  {
      public:
  
      explicit Elevator(string the){
          status = "STOPPED";
          passengerCount = 0;
          name = the;        
      }//end constructor
  
      int addtoQueue(Passenger person){
          if (this-&gt;passengerCount &lt; 8){
              this-&gt;pickupQueue.push(person);
              return 0;
          }else{
              cout &lt;&lt; "Error -- full" &lt;&lt; endl;
              return 1;
          } //end
  
      } //end addtoQueue
  
      void changePassengerCount(int change){
          passengerCount += change;
      }
  
      string getStatus(){
          return status;
      }
  
      void setStatus(string status){
          status = status;
      }
  
      void addStop(int location){
          stops.push(location);
      }
  
      int getStops(){
          return stops.size();
      }
  
      string getName(){
          return name;
      }
  
      int getRoute(){
          return stops.front();
      }
  
      bool checkCount(){
          if (passengerCount &gt; 8){
              return false;
          }else{
              return true;
          }
      }
  
      int printCount(){
          return passengerCount;
      }
  
      void printQueue(){
          queue&lt;int&gt; copy = stops;
  
          while(!copy.empty()){
              cout &lt;&lt; copy.front() &lt;&lt; " ";
              copy.pop();
          }
  
          cout &lt;&lt; endl;
      }
  
      private:
      string status;
      queue&lt;Passenger&gt; pickupQueue;
      int passengerCount;
      queue&lt;int&gt; stops;
      string name;
  
  }; //end passenger
  </code></pre>
  
  <p>I am reading a <code>csv</code> file into a <code>vector</code> of <code>Passenger</code> objects, and then what I want to do is fill some <code>queue</code> objects in each <code>Elevator</code> object with those <code>Passenger</code> objects. However, it seems as though none of the objects in the <code>Elevator</code> class are actually updating. For example, <code>passengerCount</code> and <code>Queue Size</code> never go above one. I cannot figure out why.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;sstream&gt;
  #include "Passenger.h"
  using namespace std;
  
  int time = 0;
  
  int main(){
      vector&lt;Passenger&gt; passengers;
      Elevator elevatorOne = Elevator("elevatorOne");
      Elevator elevatorTwo = Elevator("elevatorTwo");
      Elevator elevatorThree = Elevator("elevatorThree");
      Elevator elevatorFour = Elevator("elevatorFour");
      vector&lt;Elevator&gt; elevators;
      elevators.push_back(elevatorOne);
      elevators.push_back(elevatorTwo);
      elevators.push_back(elevatorThree);
      elevators.push_back(elevatorFour);
  
      // Code removed when building the vector of passengers by reading in the csv
  
      for(unsigned int i = 0; i &lt; passengers.size(); i++){
          //cout &lt;&lt; "Currently evaluating passenger: " &lt;&lt; i &lt;&lt; endl;
          for (Elevator currElevator : elevators){
              // If the elevator hasn't moved
              // This is one of three logic checks, but the others have been removed at the request of SO users
              if(currElevator.getStatus().compare("STOPPED") == 0 &amp;&amp; currElevator.getStops() == 0 &amp;&amp; currElevator.checkCount() == true){                
                  // Add the passenger's end floor to the current elevator's queue
                  cout &lt;&lt; "adding passenger " &lt;&lt; i &lt;&lt; " to elevator: " &lt;&lt; currElevator.getName() &lt;&lt; " because of condition 1 " &lt;&lt; endl;
                  currElevator.addStop(passengers[i].endFloor);
                  currElevator.changePassengerCount(1);
                  cout &lt;&lt; "Queue Size: " &lt;&lt; currElevator.getStops() &lt;&lt; endl;
                  cout &lt;&lt; "Passenger Count: " &lt;&lt; currElevator.printCount() &lt;&lt; endl;
                  if(passengers[i].endFloor &gt; currElevator.getRoute()){
                      currElevator.setStatus("MOVING UP");
                  } else{
                      currElevator.setStatus("MOVING DOWN");
                  }
  
                  break;                     
              } //end if
  
              else{
                  // If none of these conditions match, move on to the next elevator
                  continue;
              } //end else
          } //end looping through elevators
      } //end looping through passengers
  } //end main
  </code></pre>
  
  <p>I am getting results like:</p>
  
  <pre><code>adding passenger 0 to elevator: elevatorOne because of condition 1
  Queue Size: 1
  Passenger Count: 1
  adding passenger 1 to elevator: elevatorOne because of condition 1
  Queue Size: 1
  Passenger Count: 1
  adding passenger 2 to elevator: elevatorOne because of condition 1
  Queue Size: 1
  </code></pre>
  
  <p>But would expect to see:</p>
  
  <pre><code>adding passenger 0 to elevator: elevatorOne because of condition 1
  Queue Size: 1
  Passenger Count: 1
  adding passenger 1 to elevator: elevatorOne because of condition 1
  Queue Size: 2
  Passenger Count: 2
  adding passenger 2 to elevator: elevatorOne because of condition 1
  Queue Size: 3
  Passenger Count: 3
  </code></pre>
  
  <p>etc</p>