How to reference an array

Im trying to reference my array in another function but i keep getting errors.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
void player::store()
{
    int menuChoice;
    int amountChoice = 0;
    int items[4] = {0,0,0,0};
    string inv;


    cout << "\nWelcome to the store what do you want to buy?" << endl;
    cout << "1) Health Pack - $20" << endl;
    cout << "2) Pistol Ammo - $30" << endl;
    cout << "3) Shotgun Ammo - $50" << endl;
    cout << "4) Rifle Ammo - $80" << endl;
    cin >> menuChoice;

        switch(menuChoice)
        {
            case 1:
                {
                    cout << "How many Health Packs do you want to buy?" << endl;
                    cin >> amountChoice;

                    items[1] = amountChoice;
                    amountChoice = 0;

                }break;

            case 2:
                {
                    cout << "How much Pistol Ammo do you want to buy?" << endl;
                    cin >> amountChoice;

                    items[2] = amountChoice;
                    amountChoice = 0;

                }break;

            case 3:
                {
                    cout << "How much Shotgun Ammo do you want to buy?" << endl;
                    cin >> amountChoice;

                    items[3] = amountChoice;
                    amountChoice = 0;

                }break;

            case 4:
                {
                    cout << "How much Rifle Ammo do you want to buy?" << endl;
                    cin >> amountChoice;

                    items[4] = amountChoice;
                    amountChoice = 0;

                }break;

            default:
                cout << "Thank you for shopping at the store!!" << endl;
        }

        cout << "Items bought:\n" << endl;

        cout << "Health Packs: " << items[1] << endl;
        cout << "Pistol Ammo: " << items[2] << " rounds" << endl;
        cout << "Shotgun Ammo: " << items[3] << " rounds" << endl;
        cout << "Rifle Ammo: " << items[4] << " rounds" << endl;

        backpack();
}

void player::backpack(int &items[4])
{
    cout << items[1] << endl;
    cout << items[2] << endl;
    cout << items[3] << endl;
    cout << items[4] << endl;
}



errors

C:\Users\Chay\Desktop\Dinosaur Arena\MainGame.h|81|error: declaration of 'items' as array of references|
C:\Users\Chay\Desktop\Dinosaur Arena\MainGame.h|81|error: prototype for 'void player::backpack(...)' does not match any in class 'player'|
C:\Users\Chay\Desktop\Dinosaur Arena\player.h|24|error: candidate is: void player::backpack()|
1
2
void player::backpack(int (&items)[4])
{...

I got these errors after making the changes:

C:\Users\Chay\Desktop\Dinosaur Arena\MainGame.h|81|error: prototype for 'void player::backpack(int (&)[4])' does not match any in class 'player'|
C:\Users\Chay\Desktop\Dinosaur Arena\player.h|24|error: candidate is: void player::backpack()|
||=== Build finished: 2 errors, 0 warnings ===|
Opps wait a minute, this isnt the beginners forum sorry. ignore this
Topic archived. No new replies allowed.