For a fixed array,
// will initialize the missing elements to 0 as well
A[max_row][max_col] = {0,}
Can we achieve this in dynamic arrays (multidimensional, in particular)?
Side question: if we can't, and we are forced to use nested loop, then how does the initialization time of the trick above compared to nested loop initialization?
I don't want to vector, otherwise this question is meaningless. Thanks for the advise :)
If you do this: new int[N]() /* note parenthesis */, then they are all zero initialized.
You should really use a std::vector, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With