I have a curiosity.
I would like to know if it is more efficient this code
int a(0);
for(int i=0;i!=10;++i){
a=0;
for(int j=0;j!=10;++j){
// perform some operations on a
}
}
or this code
for(int i=0;i!=10;++i){
int a(0);
for(int j=0;j!=10;++j){
// perform some operations on a
}
}
or it is exactly the some in term of performance. I understand that the answer may depend on the compiler and its inner optimization technique but I am curios to understand if there is any difference.
Thank you,
Marco.
Answer
In any modern C++ compiler there's no difference what-so-ever.
No comments:
Post a Comment