I am having problems with the part where the functions finds the total number of entries in the favorites function. The compiler says i am trying to convert an int into an an int*. I cant seem to understand why it thinks i am trying to convert the array into an integer.
#include <iostream>
using namespace std;
enum DrinksType {COKE, PEPSI, SPRITE, DR_PEPPER};
int favorites(int sum[]);
void Prompt();
int main ()
{
int sums[4];
int number;
int total;
DrinksType index;
for (index = COKE; index <= DR_PEPPER; index = DrinksType(index+1))
sums[index] = 0;
Prompt();
cin >> number;
while (number != 4)
{
switch(number)
{
case 0:
sums[0]++;
break;
case 1:
sums[1]++;
break;
case 2:
sums[2]++;
break;
case 3:
sums[3]++;
break;
}
Prompt();
cin >> number;
}
total = favorites (sums[4]);
cout << "Coke: " << sums[0] << endl;
cout << "Pepsi: " << sums[1] << endl;
cout << "Sprite: " << sums[2] << endl;
cout << "Dr. Pepper: " << sums[3] << endl;
cout << "The number of responses is: " << total;
return 0;
}
//*******************************************************
void Prompt()
{
cout << "Enter a 0 if your favorite is a Coke." << endl;
cout << "Enter a 1 if your favorite is a Pepsi." << endl;
cout << "Enter a 2 if your favorite is a Sprite." << endl;
cout << "Enter a 3 if your favorite is a Dr. Pepper." << endl;
cout << "Enter a 4 if you wish to quit the survey." << endl;
}
int favorites (int sum[])
{
int total = 0;
for (int i = 0; i<4; i++)
total = total + sum[i];
return total;
}
favorites