C++ Pass a reference to an array to function

前端 未结 3 797
悲&欢浪女
悲&欢浪女 2020-12-17 04:05

Given to functions void main() and void hello(byte* a[4]). Main function has an array of four bytes. The array\'s reference needs to be passed to the function hello for mani

3条回答
  •  天涯浪人
    2020-12-17 04:50

    Arrays are already passed by pointer.

    So this:

    int a(int array[]) {
    }
    

    Is the same as doing this:

    int a(int * array) {
    }
    

    Doing this:

    void hello(byte (&a)[4])
    

    only allows arrays with a length of 4 to be passed in.

提交回复
热议问题