Another hint, you should really try to keep variables as local and within as smaller scope as possible. Code will be easier to read,easier to maintain and the compiler will have a much easier time optimizing.
Too many people code C++ as if it is code compiled in the 1980s.
It is perfectly fine to declare the. Loop counter within the for-statement,your compiler will thank you. Likewise, declare variables within loops if the context is only within the loops-scope- again, the compiler will prefer this to a higher scoped variable and will apply better optimization.
Too many people code C++ as if it is code compiled in the 1980s.
It is perfectly fine to declare the. Loop counter within the for-statement,your compiler will thank you. Likewise, declare variables within loops if the context is only within the loops-scope- again, the compiler will prefer this to a higher scoped variable and will apply better optimization.