title: C++ pass list as a parameter to a function
body: <p>I'm trying to build a very simple address book. I created a Contact class and the address book is a simple list. I'm trying to build a function to allow the user to add contacts to the address book. If I take my code outside of the function, it works OK. However, if I put it in, it doesn't work. I believe it's a passing by reference vs passing by value problem which I'm not treating as I should. This is the code for the function:</p>
  
  <pre><code>void add_contact(list&lt;Contact&gt; address_book)
  {
       //the local variables to be used to create a new Contact
       string first_name, last_name, tel;
  
       cout &lt;&lt; "Enter the first name of your contact and press enter: ";
       cin &gt;&gt; first_name;
       cout &lt;&lt; "Enter the last name of your contact and press enter: ";
       cin &gt;&gt; last_name;
       cout &lt;&lt; "Enter the telephone number of your contact and press enter: ";
       cin &gt;&gt; tel;
  
       address_book.push_back(Contact(first_name, last_name, tel));
  }
  </code></pre>
  
  <p>I don't get any errors however when I try to display all contacts, I can see only the original ones.</p>