c++ int initialization

最近的C++ int initialization 总是出错,在这里提醒自己一下。

无论是数组还是变量的初始化,一定要explicitly set 0.

example:


int* rows;

int* cols;

int diagonal;

int anti_diagonal;

rows = new int[n]{0};

cols = new int[n]{0};

diagonal = 0;

anti_diagonal = 0;

你可能感兴趣的:(c++ int initialization)