Difference between [square brackets] and *asterisk

后端 未结 5 2104
遇见更好的自我
遇见更好的自我 2020-11-27 04:03

If you write a C++ function like

void readEmStar( int *arrayOfInt )
{
}

vs a C++ function like:

void readEmSquare( int arrayOfInt[] )
{
}
         


        
5条回答
  •  无人及你
    2020-11-27 04:39

    There is no difference between your two codes, apart from the different style obviously. In both cases the array is passed by reference and not by value, as function parameters type *x and type x[] are semantically the same.

提交回复
热议问题