How can I declare and define multiple variables in one line using C++?

后端 未结 10 1706
抹茶落季
抹茶落季 2020-11-27 11:09

I always though that if I declare these three variables that they will all have the value 0

int column, row, index = 0;

Bu

10条回答
  •  独厮守ぢ
    2020-11-27 11:45

    Possible approaches:

    • Initialize all local variables with zero.
    • Have an array, memset or {0} the array.
    • Make it global or static.
    • Put them in struct, and memset or have a constructor that would initialize them to zero.

提交回复
热议问题