こんにちは私はあなたがあなたのお得情報を入力するプログラムを作成しようとしていますし、終了した後、お得な情報のリストを取得する必要があります。私はそれらを配列で表示させたいが、私はエラーを取得し続けるオブジェクトへのポインタを持っている必要があります。エラーを示すC++配列
#include <iostream>
using namespace std;
int main() {
int deal;
int date;
int type;
int quantity;
int quality;
int end;
int find;
for (deal = 0; deal < 5000; deal++) {
for (date = 0; date < 5000; date++) {
cout << " enter the year,month,day and hour of pruchase in this format YYYY/MM/DD/HH/MM" << endl;
cin >> date;
for (type = 0; type < 5000; type++) {
cout << " enter the mushroom type. 1 = манатарка, 2 = печурка, 3 = кладница 4 = пачи крак, 5 = съренла, 6 = друг вид гъба "<<endl;
cin >> type;
for (quantity = 0; quantity < 5000; quantity++) {
cout << " enter the mushroom quantity " << endl;
cin >> quantity;
for (quality = 0; quality < 5000; quality++) {
cout << "enter the mushroom quality from 1 to 3 " << endl;
cin >> quality;
cout << "Press 1 for a new deal , press 2 to exit" << endl;
cin >> end;
if (end = 2)
{
deal[date];
goto stop;
}
}
}
}
}
}
stop:
for (find = 0; find < 5000; find++) {
int find = 0;
cout << date[find] << ", " << type[find] << ", " << quantity[find] << ", " << quality[find];
//error must have a pointer to object
}
}
いくつかの本を読んでください: 'deal [date];'はナンセンスです。 –
'date'、' type'などは配列ではなく、ただ一つの 'int'sなので、それらの要素にアクセスすることはできません。また、これを個人的に服用しないでください。しかし、あなたのコードは、悪い習慣やエラーでいっぱいです。私はどこから学んでいるのかわかりませんが、おそらくあなたは[推薦された本のリスト](http://stackoverflow.com/q/388242/1171191)から何かを選ぶことを検討すべきです。 – BoBTFish
ループ内に複数のforループがあると、通常は設計上何か問題があります。 –