I came across a problem where i need to declare a 2D array dynamically. The number of rows were known(i.e 2) while the number of columns are to taken as input.
I used this technique :
cin>>size;
int **outer = new int*[2];
int outer[0] = new int[size];
int outer [1] = new int[size];
But this gave an error : conflicting declaration 'int outer [0]'
Than i fixed the problem by changing my code to :
cin>>size; // size of the column
int **outer = new int*[2];
for(int i=0;i<2;i++)
outer[i] = new int[size];
So, i want to know why can't i declare 2D array like as that of 1st , bcz i am declaring it after i have declared and defined the size.
Aucun commentaire:
Enregistrer un commentaire