title: An object is not getting updated when sending by ref (C++)
body: <p>I'm trying to make a program for a queue of customers (FIFO),
  I've already made both of the classes, but when I send an object by ref and I try to deposit him account, its getting updated only inside th function, but when it gets back to main, I can't see it updated and it stays on 0.
  The issue is that when I enter deposit with c3, its adding 333 to the account, but when I try to print q1, it prints 0.</p>
  
  <p>My code:</p>
  
  <p><strong>Customer.cpp</strong></p>
  
  <pre><code>Customer::Customer(string name)
  {
      this-&gt;name = name;
      this-&gt;customerNum = accountId;
      this-&gt;next = NULL;
      this-&gt;accountBalance = 0;
      accountId++;
  }
  
  // Copy c'tor
  Customer::Customer(const Customer&amp; x) : 
      accountBalance(x.accountBalance), customerNum(x.customerNum), name(x.name) {
          this-&gt;next = NULL;
  }
  void Customer::deposit(int amountToDeposit) {
      this-&gt;accountBalance += amountToDeposit;
      cout &lt;&lt; "Added " &lt;&lt; amountToDeposit &lt;&lt; " to your account." &lt;&lt; endl;
      cout &lt;&lt; "The new balance is: " &lt;&lt; this-&gt;accountBalance &lt;&lt; endl;
  }
  
  </code></pre>
  
  <p><strong>Queue.cpp</strong></p>
  
  <pre><code>
  // copy c'tor
  Queue::Queue(Queue&amp; x) {
      this-&gt;first = x.first;
      this-&gt;rear = x.rear;
  }
  
  
  void Queue::print() {
      Queue* temp = new Queue(*this);
      if (temp-&gt;first == NULL) {
          cout &lt;&lt; "The queue is empty!" &lt;&lt; endl;
      }
      else if (temp-&gt;first != NULL &amp;&amp; temp-&gt;rear == NULL) {
          temp-&gt;first-&gt;printAccount();
      }
      else {
          while (temp-&gt;first != NULL) {
              temp-&gt;first-&gt;printAccount();
              temp-&gt;first = temp-&gt;first-&gt;getNext();
          }
      }
  }
  
  </code></pre>
  
  <p><strong>Main</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include "Customer.h"
  #include "Queue.h"
  
  using namespace std;
  
  
  int main() {
  
      Queue q1;
      cout &lt;&lt; boolalpha;
      cout &lt;&lt; "Is q1 empty ? " &lt;&lt; q1.isEmpty() &lt;&lt; endl;
      Customer c1 = Customer("Number One");
      Customer c2 = (string) "Number Two";
      Customer *c3 = new Customer("Number Three");
      q1.enqueue(c1);
      cout &lt;&lt; "Is q1 empty ? " &lt;&lt; q1.isEmpty() &lt;&lt; endl;
      q1.enqueue(c2);
      q1.enqueue(*c3);
      q1.print();
      cout &lt;&lt; endl;
  
      c1.deposit(111);
      c2.deposit(222);
      c3-&gt;deposit(333); **This is the line which is not getting updated.(I can't change the main, I need another solution)**
      q1.print(); ** prints 0 in account balance for c3**
      cout &lt;&lt; endl;
  
      return 0;
  }
  
  </code></pre>
  
  <p>Queue has 2 pointer for rear and first(front), and it saves the customers in the queue one by one, then when I want to print the queue it will print the front of the queue and then go to the next of this node and him the front.</p>