I have a variable int*** dp
, and I want to pass it to a function by reference to initalize it. But when I try to call the function:
int*** dp;
int c1, c2, c3;
void initialize(int*** d)
{
d = new int**[c1 + 1];
for(int i = 0; i <= c1; i++)
{
d[i] = new int*[c2 + 1];
for(int j = 0; j <= c2; j++)
{
d[i][j] = new int[c3 + 1];
for(int k = 0; k <= c3; k++)
{
d[i][j][k] = 0;
}
}
}
d[0][0][0] = 1;
}
initialize(dp);
I get the following compile error: invalid conversion from 'int' to 'int***' [-fpermissive].
Even if I try to pass it by reference:
void initialize(int*** &d)
It still doesn't work! Can you explain me why it doesn't work and how I can fix it?