Passing 2-D array as argument

后端 未结 6 885
误落风尘
误落风尘 2020-12-31 14:03

I am trying to pass a 2-d array to a function which accept a pointer to pointer. And I have learnt that a 2-d array is nothing a pointer to pointer(pointer to 1-D array). I

6条回答
  •  庸人自扰
    2020-12-31 14:33

    Why don't use std::vector instead of "raw" arrays. Advantages:
    1. It can dynamically grow.
    2. There is no issues about passing arguments to the function. I.e. try to call void myFuntion(int array[SIZE1][SIZE2]); with array, that has some different sizes not SIZE1 and SIZE2

提交回复
热议问题