title: two pointers same reference
body: <p>I'm really new to C++, I just learned it a couple of weeks ago. I have a problem with 2 pointers individually pointing to the same reference. When I try to reassign *workingOn then *user turns into garbage.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>    std::cout &lt;&lt; static_cast&lt;int&gt; (user-&gt;getPermission()) &lt;&lt; endl; // return 0
  
  Customer  c_temp(username, password, Permission::CUSTOMER);
  s_customer.push_back(c_temp);
  workingOn = &amp;s_customer[s_customer.size() - 1];
  std::cout &lt;&lt; static_cast&lt;int&gt; (user-&gt;getPermission()) &lt;&lt; endl; // return random memory
  
  return customerLoggedInScreen();
  </code></pre>
  
  <p>get Permission is an enum that can either return 0,1,2 which include manager, customer, maintenance.</p>
  
  <p>*user can either be a manager or customer
  *workingOn is the person you're working on. Which could be yourself (as the customer)</p>
  
  <p>The code could of been designed better... but I wasn't too comfortable with polymorphism and C++</p>
  
  <p>I'm trying to change the person the user is workingOn but afterwards my pointer turns into garbage memory. Initially the user and the person working on are the same.</p>
  
  <p>Here is the initialization of the user:</p>
  
  <pre><code>void Controller::login()
  {
  bool loggedIN = false;
  
  using namespace std;
  string input_password, input_username;
  
  //call the login screen
  
      UI.login(input_username, input_password);
  
  
      /*
      If the user is not a customer we will login as a manager
      */
      for (int i = 0; i &lt; s_customer.size(); ++i) {
          user = &amp;s_customer[i];
  
          if (user-&gt;getUsername().compare(input_username) == 0 &amp;&amp; user-&gt;getPassword().compare(input_password) == 0) {
              user_loggedIn = input_username; // store the person who is logged in
  
              if (user-&gt;getPermission() == Permission::CUSTOMER) {
                  workingOn= &amp;s_customer[i];
                  return whatUItoDisplay();
              }
              return whatUItoDisplay();
          }
      }
  </code></pre>
  
  <p>}</p>
  
  <p>in my header I have:
  public:
      std::vector  s_customer; // This will hold all the customers in the program</p>
  
  <pre><code>Interface UI;
  std::string user_loggedIn;
  Customer *user = nullptr;
  Customer *workingOn = nullptr;
  </code></pre>