So as an java developer I've always known to avoid for loops but as new to C++ I'm wondering if due to lack of overhead it wont matter performance wise to use a for loop.
Example:
I'm making a matrix (4*4) class and I want to set all elements to 0. Should I use:
for(int i = 0; i < 16;i++)<br>
elements[i] = 0; <br>
or just set them all by hand
elements[0] = 0; elements [1] = 0; elements [1] = 0; etc....
When its only 16 elements this don't matter much for me to write I've just learned as a java developer that never use for loops if you don't have to. But in C++ its native and perhaps will be faster?
I've just learned as a java developer that never use for loops if you don't have toWho taught you to avoid for loops? Loops are an important part in programming as it can cut down on code