ダイナミック(これが正しい単語であるかどうかわからない)オブジェクトを作成する最適な方法は何ですか? 新しい「動的」オブジェクトの作成?
Person man[10];
cout << "MENU" << endl;
cout << "1. Add a person to the list" << endl;
cout << "2. Delete a person from the list" << endl;
cout << "3. Change a person's information'" << endl;
cout << "4. Locate a person by ID number" << endl;
cout << "5. Locate a person by last name" << endl;
cout << "6. Print the list on the screen" << endl;
cout << "7. Load the list from a file" << endl;
cout << "8. Save the list to a file" << endl;
cout << "9. Exit the program" << endl;
cin >> a;
if (a == 1) {
if (i <= 10) {
Person man[i];
cout << "Please enter your last name: " ;
cin >> last;
man[i].setLastName(last);
i++;
cout << man[i].getLastName();
}
}
私はこれを実行する
が、私は私の最後の名前を入力させていただいておりますが、私は、プログラムが実行を停止するEnterキーを押したとき:たとえば、私が実行した場合、次の。これの理由は何ですか?これらのオブジェクトの「プロファイル」を作成するためのより良い方法がありますか?ありがとうございます。これがばかげた質問であればごめんなさい。
'Person man [10];' - あなたはすでに10個の 'Person'オブジェクトを作成しています。 'std :: vector'を参照してください。 – PaulMcKenzie