how do i pass an array of class objects to a function? this is what my code looks like so far..
i was told that the function header was correct but i cannot figure out how to pass in an array of objects to this method.. i was thinking .. int fitness = play(cellArray, 100); -- but that didnt work.. any ideas?Code:int play(Cell **cellArray, int size) { if(!cellArray) { cerr << "Board contains no live cells." << endl; exit(1); } Cell temp[10][10]; //temp array so the final values will not be altered for(int i=0; i<10; i++) { for(int j=0; j<10; j++) { temp[i][j] = cellArray[i][j].getValue(); } } int legalTurn = 0; int fitness = 0; int lastTurn = 0; bool anyLife = false; //for loop that goes through the array and sends the values to the //check function to determine if the cell should be alive or dead for(int x=0; x<100; x++) { for(int y=0; y<10; y++) { for(int z=0; z<10; z++) { int living = check(c, y, z); if(living > 0) { temp[y][z] = 1; anyLife = true; if(x==100-1) { lastTurn++; } } else temp[y][z] = 0; } } if(anyLife) { legalTurn++; } anyLife = false; for(int i=0; i<10; i++) { for(int j=0; j<10; j++) { cellArray[i][j] = temp[i][j].getValue(); } } } fitness = legalTurn * lastTurn; return fitness; }