Dymanic Array

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
   //why when we make dymanic array we don't write this code
    int row,column;
    cout<<"Number of rows : ";
    cin>>row;
    cout<<"Number of columns : ";
    cin>>column;
    int matrix_1[row][column] , matrix_2[row][column];
   //And write this code

   int size;

  cin >> size;

  int *array = new int[size];

  delete [] array;
Because that syntax is used for arrays allocated on the stack. Dynamic arrays have semantics different from those of stack arrays. Most importantly, a function is capable of returning a dynamic array it has allocated.
Topic archived. No new replies allowed.