Confused with object arrays in C++

前端 未结 7 662
后悔当初
后悔当初 2021-01-30 03:56

So I first learned Java and now I\'m trying to switch over to C++. I\'m having a little difficulty getting arrays to work correctly.

Right now I am simply trying to crea

7条回答
  •  伪装坚强ぢ
    2021-01-30 04:01

    Here you have allocated some memory to store an array of one Player (not really useful but it's a first step).

    Your variable "players" is now storing the address of the first (and only) slot in this array. Then by accessing the first Player with players[0], you are able to directly write/read in its memory and no more allocation is needed.

提交回复
热议问题