CreateList 関数は次のことを行う必要があります。 1. ユーザーに食料品店の名前を尋ねます。2. ユーザーが「完了」と入力するまで、この食料品店のアイテムのリストを入力するようにユーザーに依頼します。3. 入力された文字列のベクトルに項目を追加します。4. 表示: 「食料品店名リストに商品を追加しました。」ここで、「item」は入力したアイテム、「grocery store name」は上記のステップ 1 で入力した名前です。
void CreateList()
{
string store;
string item;
int count = 0;
cout<<"What is the grocery store name"<<endl;
cin>>store;
vector<string> store;
cout<<"Enter a list of items for this grocery store one at a time. When you are done, type done."<<endl;
cin>>item;
store[count] = item; //error saying no conversion?
count++;
cout<<"Added "<<item<<"to "<<store<<"list"<<endl;
bool finished=true;
while (finished = true)
{
cout<<"Enter a list of items for this grocery store one at a time. When you are done, type done."<<endl;
cin>>item;
if (item == "done")
break;
store[count] = item; //error saying no conversion?
count++;
cout<<"Added "<<item<<"to "<<store<<"list"<<endl;
}
}
私の関数についていくつか質問がありましたが、変換エラーがどこから来ているのかわからず、これを do while ループに実装できますか? 答えはできるだけシンプルにしてください。これは、Python からの移行中に C++ で初めて試みたものです。御時間ありがとうございます。