Expand|Select|Wrap|Line Numbers
- int array[5][10];
Expand|Select|Wrap|Line Numbers
- int array[5][10];
- int (*ptr)[10] = array;
Expand|Select|Wrap|Line Numbers
- int* array = new int[value];
- int (*ptr)[10] = new int[value][10];
- int (*ptr)[10][15] = new int[value][10][15];
Using an int** for an array of arrays is incorrect and produces wrong answers using pointer arithmetic. The compiler knows this so it won't compile this code:
Expand|Select|Wrap|Line Numbers
- int** ptr = new int[value][10]; //ERROR
Likewise:
Expand|Select|Wrap|Line Numbers
- int*** ptr = new int[value][10][15]; //ERROR
No comments:
Post a Comment