私は非常に簡単なアドレス帳を構築しようとしています。私はContactクラスを作成し、アドレス帳は単純なリストです。私はユーザーがアドレス帳に連絡先を追加できるようにするための機能を構築しようとしています。私のコードを関数の外に持っていけば、うまくいきます。しかし、私はそれを入れて、それは動作しません。私はそれが参考としての渡しだと私は私が必要としているように扱っていない値の問題を渡すと信じています。これは、関数のコードです:私はすべての連絡先を表示しようとすると、私はしかし、すべてのエラーを得ることはありません関数へのパラメータとしてのC++パスリスト
void add_contact(list<Contact> address_book)
{
//the local variables to be used to create a new Contact
string first_name, last_name, tel;
cout << "Enter the first name of your contact and press enter: ";
cin >> first_name;
cout << "Enter the last name of your contact and press enter: ";
cin >> last_name;
cout << "Enter the telephone number of your contact and press enter: ";
cin >> tel;
address_book.push_back(Contact(first_name, last_name, tel));
}
、私は唯一のオリジナルのものを見ることができます。
'add_contact(アドレス帳)を呼び出すときに'リストアドレス帳には、 '更新されていません;' –
Adrian