I am trying to create a very simple address book. I created the Contact class, and the address book is a simple list. I am trying to create a function that allows the user to add contacts to the address book. If I take the code outside the function, it will work fine. However, if I insert it, this will not work. I believe that this is a referral transfer versus a transfer on the value problem, which I do not consider as it should. This is the code for the function:
void add_contact(list<Contact> address_book) {
I do not get any errors, however, when I try to display all the contacts, I can only see the original ones.
c ++ list pass-by-reference pass-by-value
Adrian
source share