title: New command not making a new object C++
body: <p>I will start by explaining my issue, and then provide a good portion of the code.
  I and filling a queue with a custom class called process. Using this line:</p>
  <pre><code>ProcessQueue.push(new Process(inputs[0], inputs[1], inputs[2], inputs[3], inputs[4]));
  </code></pre>
  <p>This all seems well and good, when the loop is done Process queue is filled with pointers.
  However upon further inspection I found out they all point to the SAME object?</p>
  <p>Finding this curious, I stepped into the constructor on each iteration of the loop.</p>
  <blockquote>
  <p>First iteration: when the constructor is entered all instance variables are null (as expected)</p>
  <p>Second iteration: upon entering the constructor, all instance variables contain the values given to the object in the first iteration (ie: the same object)</p>
  </blockquote>
  <p>Furthermore later when I use the queue I have confirmed that every pointer in the queue is referring to the same process object. (I can tell this because process contains a state and if loop through the queue changing the state, I will find the state already changed for the second pointer)</p>
  <p>I suspect I must have done something wrong with the creation of me class. so here it is in its entirety.</p>
  <p>Process.h</p>
  <pre><code>    #pragma once
      class Process
      {
      public:
          Process(int _processId, int _arrivalTime, int _CPUTime,
              int _IOFrequency, int _IODuration);
          ~Process();
  
          bool HasArrived(int time);
          bool HasCompleted();
          bool HasFinishedBurst();
          bool HasFinishedIO();
          int GetQueueNum();
          int GetID();
          void SetQueueNum(int i);
          void SetToReady();
          void Run();
          void PerformIO();
      };
  </code></pre>
  <p>Process.cpp</p>
  <pre><code>    #include &quot;stdafx.h&quot;
      #include &quot;Process.h&quot;
      #include &lt;string&gt;
  
      using namespace std;
  
      int processId;
      int arrivalTime;
      int CPUTime;
      int IOFrequency;
      int IODuration;
  
      int Ticks;
      int CPUConsumption;
      int CPUBurstSize;
      int queueNumber;
      int IOBurstCount;
      string state;
  
  
      Process::Process(int _processId, int _arrivalTime, int _CPUTime,
          int _IOFrequency, int _IODuration)
      {
          processId = _processId;
          arrivalTime = _arrivalTime;
          CPUTime = _CPUTime;
          IOFrequency = _IOFrequency;
          IODuration = _IODuration;
          IOBurstCount = 0;
          CPUConsumption = 0;
          Ticks = 0;
          queueNumber = 0;
  
          state = &quot;None&quot;;
          printf(&quot;%d: %s\n&quot;, processId,state.c_str());
  
          int excess = CPUTime % IOFrequency;
          if (excess == 0)
          {
              CPUBurstSize = CPUTime / IOFrequency;
          }
          else
          {
              CPUBurstSize = (CPUTime - excess) / (IOFrequency - 1);
          }
      }
  
      Process::~Process()
      {
      }
  
      bool Process::HasArrived(int time)
      {
          if (arrivalTime &lt;= time)
          {
              if (state.compare(&quot;Newly Arrived&quot;) == 0)
              {
                  printf(&quot;Already arrived!\n&quot;);
              }
              state = &quot;Newly Arrived&quot;;
              printf(&quot;%d: %s\n&quot;, processId, state.c_str());
              return true;
          }
          else
          {
              return false;
          }
  
      }
  
      bool Process::HasCompleted()
      {
          if (CPUConsumption == CPUTime &amp;&amp; IOBurstCount == IOFrequency)
          {
              state = &quot;Finished&quot;;
              printf(&quot;%d: %s\n&quot;, processId, state.c_str());
              return true;
          }
          else
          {
              return false;
          }
      }
  
      bool Process::HasFinishedBurst()
      {
          if (Ticks == CPUBurstSize)
          {
              Ticks = 0;
              state = &quot;Blocked&quot;;
              printf(&quot;%d: %s\n&quot;, processId, state.c_str());
              return true;
          }
          else
          {
              return false;
          }
      }
  
      bool Process::HasFinishedIO()
      {
          if (Ticks &gt;= IODuration)
          {
              IOBurstCount++;
              Ticks = 0;
              return true;
          }
          else
          {
              return false;
          }
      }
  
      void Process::SetToReady()
      {
          state = &quot;Ready&quot;;
          printf(&quot;%d: %s\n&quot;, processId, state.c_str());
      }
  
      void Process::Run()
      {
          state = &quot;Running&quot;;
          printf(&quot;%d: %s\n&quot;, processId, state.c_str());
          Ticks++;
          CPUConsumption++;
      }
  
      void Process::PerformIO()
      {
          Ticks++;
      }
  
      int Process::GetQueueNum()
      {
          return queueNumber;
      }
  
      void Process::SetQueueNum(int i)
      {
          queueNumber = i;
      }
  
      int Process::GetID()
      {
          return processId;
      }
  </code></pre>
  <p>I suspect I have somehow created this as a static class without meaning too...</p>