How to zero array members when my compiler isn't standard conform

前端 未结 3 1129
独厮守ぢ
独厮守ぢ 2021-01-19 05:29

My compiler (C++Builder6) syntactically allows array member initialization (at least with zero), but actually it doesn\'t really do it. So the assert in the example given be

3条回答
  •  一生所求
    2021-01-19 05:52

    You may use fill_n like suggested in: C/C++ initialization of a normal array with one default value

    If no fill_n is available, you can always use memset like:

    TT() {memset(b, 0, sizeof b);}
    

提交回复
热议问题