c ++ Übergabe von 2D-Arrays an Funktionen
Ich weiß, dass mein Code noch nicht fertig ist, aber ich frage nicht danach. Es soll Nahrung geben, die von 3 Affen in einer Woche gegessen wird, und anderes Zeug. Aber ich habe einen Haken bekommen. Es gibt mir einen Fehler (Fehler: kein Operator "<<" stimmt mit diesen Operanden überein), wenn ich das cin in die Funktion poundsEaten stelle. Übergebe ich das Array nicht richtig, funktioniert es deshalb nicht? Danke für jede Hilfe
#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
}
}
}