No matching function for call to 'enterATab'

I keep getting an error message "No matching function for call to 'enterATab' " and I just can't seem to figure out what is going on. When looking online for some help none of it seems relevant to me. I have a feeling it is something silly that I am just not seeing but I have been stuck for couple hours now.


Thanks in advance




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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;


// global constants
const int MAX_CUSTOMERS = 200;
const double BURGER_COST = 11.75;
const double FRIES_COST = 3.49;
const double SHAKE_COST = 5.65;
const double COKE_COST = 2.99;


struct tab {
    int burgerCount;
    int friesCount;
    int shakesCount;
    int sodasCount;
    double total;
    int customers[MAX_CUSTOMERS];
};

// Function prototypes
void enterATab (tab customers[], int currentCustomerCount);
void viewATab (tab customers[], int currentCustomerCount);



int main()

{
    tab customers[MAX_CUSTOMERS];
    tab total;
    int currentCustomerCount = 0;
    int exit = 1;
    char input;
    
    
    
    
    while (exit == 1)
    {
        
    cout << "Welcome to... Jackrabbit Slim's!" << endl;
    cout << "What would you like to do: (e)nter a new tab, (v)iew a previous tab, or (q)uit?" << endl;
        cin >> input;
    
        if (input == 'e')
        {
        enterATab (customers, currentCustomerCount);
        
        }
    
        if (input == 'v')
        {
            viewATab (customers, currentCustomerCount);
        }
        
        
        if (input == 'q')
        {
            
            cout << "Total customers" << currentCustomerCount << endl;
            cout << "Total revenue "  << endl;
            exit = 0;
        }
        
    }
    
    return 0;
}



//Function to enter a tab
void enterATab (tab customers[], int currentCustomerCount)
{
    tab t;
    int customerCount = 0;
    
    
    cout << "Slim's Famous speedburgers are $11.75. How many would you like? " << endl;
    cin >> t.burgerCount;
    cout << "French Fries are $3.49. How many would you like? " << endl;
    cin >> t.friesCount;
    cout << "Five-dollar Shakes are $5.65. How many would you like? " << endl;
    cin >> t.shakesCount;
    cout << "Cherry Cokes are $2.99. How many would you like? " << endl;
    cin >> t.sodasCount;
    
    
    cout << "-------------------------------------" << endl;
    cout << "Thank you for your order:" << endl;
    
    cout << customers[customerCount].burgerCount << " burgers at $" << BURGER_COST << ".\n";
    cout << customers[customerCount].friesCount << " fries at $" << FRIES_COST << ".\n";
    cout << customers[customerCount].shakesCount << " shakes at $" << SHAKE_COST << ".\n";
    cout << customers[customerCount].sodasCount << " sodas at $" << COKE_COST << ".\n";
    cout << "Total Charge: $" << t.total << ".\n";
    cout << "-------------------------------------" << endl;
}

//Function to view a tab
void viewATab (tab customers[], int currentCustomerCount)

{
    
    int tabNumber = 0;
    
    cout << "Which customer tab would you like to see? " << endl;
    
    cin >> tabNumber;
    
    tabNumber -= 1;
    
    if (tabNumber >= currentCustomerCount || tabNumber < 0)
        
        cout << "Sorry, there is no tab for that customer." << endl;
    
    else {
        
        cout << customers[tabNumber].burgerCount << " burgers at $" << BURGER_COST << ".\n";
        cout << customers[tabNumber].friesCount << " fries at $" << FRIES_COST << ".\n";
        cout << customers[tabNumber].shakesCount << " shakes at $" << SHAKE_COST << ".\n";
        cout << customers[tabNumber].sodasCount << " sodas at $" << COKE_COST << ".\n";
        
        }
}
Last edited on
The main is not done so ignore the 'q' option because I have not finished that portion yet. I can't get it to recognize my functions is it because of my headers?
There are quite a few errors in your code:
1
2
3
4
5
6
7
error C2664: 'void enterATab(tab [],int)' : cannot convert argument 1 from 'int [200]' to 'tab []'	49
error C2664: 'void viewATab(tab [],int)' : cannot convert argument 1 from 'int [200]' to 'tab []'	55
error C2065: 'total' : undeclared identifier	61
IntelliSense: argument of type "int *" is incompatible with parameter of type "tab *"	49
IntelliSense: argument of type "int *" is incompatible with parameter of type "tab *"	55
IntelliSense: identifier "total" is undefined	61
Yea only ones that I am not getting right now is the line 49 and 55 error. I know why I get the other errors for total
In line 49 you call enterATab with an int array but the function expects a array of type tab.
void enterATab (tab customers[], int currentCustomerCount);


Same on line 55 with the call to viewATab
The problem is this:
1
2
3
4
int main()

{
int customers[MAX_CUSTOMERS]; // Change int -> tab 
Line 32: You're comparing an uninitialized variable.

Line 19: What's the purpose of the int customers array inside tab?

Line 28: This should be tab.

Line 37: You call currentCustomerCount, but currentCustomerCount is uninitialized (garbage).

Line 44: total is undefined.

Line 59-81: Lots of problems here. tab t is local and goes out of scope when enterAtab exits.
currentCustomerCount needs to be passed by reference.
Line 74: You need to assign t to customers[currentCustomerCount] and increment currentCustomerCount.

Lines 75-79: These values were never set.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.



Thanks for the help I was able to get rid of the errors on my functions by getting rid of int and making it tab (stupid mistake).


When I enter my tab it accepts my numbers but when I go to view the tab it comes back with 0's. I am not sure if the problem is in my viewATab function or with the enterATab function.

Can anyone provide any further guidance? I have been going over the code for awhile now and still can't seem to find my issue.
Last edited on
The problem is in your enterATab function. Why do you enter the data in a local variable t instead of customer you pass to the function?
Topic archived. No new replies allowed.