ここの初心者は、構造化された配列の引数が関数に送信されることに問題があります。私の基本的な流血コンパイラは、私が設定した関数を気に入っていないようです。プログラム全体でいくつかの改善を行いましたが、これに何時間も苦労しています. このサイトで同等のプログラムを調べてみましたが、エラーを特定するのに十分なほど類似したものはありませんでした。私の在庫機能の仕事は、コーラなどの飲み物が 0 になったときに売り切れというメッセージを送ることです。別のコンパイラ エラーをクリアするために、関数定義を int main の後の下から上に移動しました。このプログラムはクラスの課題であり、次のテストで成功するためにポインターを使用できるため、このプログラムのどの部分についてもすべてのフィードバックを受け入れることができます。ありがとう
#include<iostream>
#include<iomanip>
using namespace std;
struct Soda
{
string name;
float price;
int inv;
};
void functInventory(Soda[],int); //prototype
void functInventory(Soda drink[],int num) //function definition
{
if ( drink[num].inv = 0)
cout << "SOLD OUT" <<endl;
}
int main()
{
const int option = 5;
string cola, rbeer, lemlime, grape, cream;
int InsAmount, choice;
int income = 0;
Soda array[option] = {
{cola, .75, 20},
{rbeer, .75, 20},
{lemlime,.75, 20},
{grape, .80, 20},
{cream, .80, 20}
};
cout << "Please choose 1-6 " << endl;
cout << " 1. Cola = $.75 " << endl;
cout << " 2. Root Beer = $.75 " << endl;
cout << " 3. Lemon Lime = $.75 " << endl;
cout << " 4. Grape Soda = $.80 " << endl;
cout << " 5. Cream Soda = $.80 " << endl;
cout << " 6. QUIT & EXIT " << endl;
switch(choice)
{
case 1: array[0].inv - 1 = array[0].inv;
income = income + .75;
functInventory(array, choice);
break;
case 2: array[1].inv - 1 = array[1].inv;
income = income + .75;
functInventory(array, choice);
break;
case 3: array[2].inv - 1 = array[2].inv;
income = income + .75;
functInventory(array, choice);
break;
case 4: array[3].inv - 1 = array[3].inv;
income = income + .80;
functInventory(array, choice);
break;
case 5: array[4].inv - 1 = array[4].inv;
functInventory(array, choice)
income = income + .80;
break;
case 6: cout << "The total amount earned is: $" << income <<endl;
break;
default:
cout << "Please enter a capital letter from 1-6 " << endl;
}
cout << "Please Tell Me How Much Money You Are Inserting: " <<endl;
cin >> InsAmount;
change = InsAmount - .75; //I will work on creating a more accurate function 4 change
cout << "your change is " << change; << " "<< endl;
return 0;
}