webForumDet fria alternativet

Hjälp att definiera funktionsprototyp

C/C++

0 svar · 1 011 visningar · startad av lillebror

Medlem sedan apr. 20041 597 inlägg
Frågan#1

Hej,

Jag har kört fast med hur jag ska definiera funktionsprototypen för funktionerna initGame och showGeneration. Båda funktionerna tar en 2-dimensionell vektor som argument. I funktionsdefinitionen skall det vara en pekare som pekar på vektorn. Hur definierar jag det här så att det blir rätt?

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <conio.h>

using namespace std;

enum Cell {Unoccupied, Occupied};

const int ROWS = 16;
const int COLS = 16; //Max usable size is 15 x 15
const char ESC = 27;

typedef Cell genType[ROWS+1][COLS+1]; //Row 0 and 16 and col 0 and 16 become a frame around the world

void initGame(int *gen[][], int *genNb); //detta är mitt förslag

int main()
{

initGame(gen, genNb); 
showGeneration(gen, genNb);
}
251 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
123 ms — deklarationer (db)
0 ms — hämta statistik (cache)
124 ms — hämta tråd, inlägg och bilagor (db)
124 ms — ändringar (db)