-6

Hello i am trying to create a program in which you enter your deals and after you're finished you should get a list of the deals . I want to get them displayed with an array but i keep getting an error must have a pointer to object.

#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
    }

}
  • 2
    Read some books: `deal[date];` is nonsense. –  Apr 10 '16 at 09:57
  • `date`, `type`, etc are not arrays, just single `int`s, so you can't try to access elements of them. Also, please don't take this personally, but your code is a confusing mess, full of bad practices and errors. I don't know where you are learning from, but perhaps you should consider picking something from our [recommended book list](http://stackoverflow.com/q/388242/1171191). – BoBTFish Apr 10 '16 at 09:58
  • 2
    When I see multiple for loops inside one another it is usually something wrong in the design. – Ed Heal Apr 10 '16 at 09:58

2 Answers2

2

Your date, find, etc. variables are defined as scalars. You cannot refer to them date[find]. You should have declared them as arrays/vectors.

BoBTFish
  • 19,167
  • 3
  • 49
  • 76
GMichael
  • 2,726
  • 1
  • 20
  • 30
0

deal should be declared as array type of int.

Zeshan Sajid
  • 559
  • 3
  • 14