C++ * vs [] as a function parameter

后端 未结 3 443
醉酒成梦
醉酒成梦 2021-01-18 11:11

What is the difference between:

void foo(item* list)
{
    cout << list[xxx].string;
}

and

void this(item list[])
{
          


        
3条回答
  •  太阳男子
    2021-01-18 12:05

    They are the same - completely synonymous. And the second is item list[], not item[]list.

    However it is customary to use [] when the parameter is used like an array and * when it's used like a pointer.

提交回复
热议问题