c ++ przekazujący tablice 2d do funkcji
Wiem, że mój kod nie jest jeszcze skończony, a ja nie proszę o zrobienie tego. Powinien wprowadzać jedzenie zjedzone przez 3 małpy w ciągu tygodnia i inne rzeczy. Ale trafiłem na szkopuł. Daje mi błąd (błąd: żaden operator „<<” nie pasuje do tych operandów, gdy umieściłem cin w funkcji poundsEaten. Czy nie przekazuję tablicy poprawnie, czy to nie działa? Dzięki za pomoc
#include <iomanip>
#include <iostream>
using namespace std;
//Global Constants
const int NUM_MONKEYS = 3;
const int DAYS = 7;
//Prototypes
void poundsEaten(const double[][DAYS],int, int);
void averageEaten();
void least();
void most();
int main()
{
//const int NUM_MONKEYS = 3;
//const int DAYS = 7;
double foodEaten[NUM_MONKEYS][DAYS]; //Array with 3 rows, 7 columns
poundsEaten(foodEaten, NUM_MONKEYS, DAYS);
system("pause");
return 0;
}
void poundsEaten(const double array[][DAYS], int rows, int cols)
{
for(int index = 0; index < rows; index++)
{
for(int count = 0; count < DAYS; count++)
{
cout << "Pounds of food eaten on day " << (index + 1);
cout << " by monkey " << (count + 1);
cin >> array[index][count];
// Here is where i get the error
}
}
}