Michael said:
Is there any practical difference between a local variable in main()
declared 'const' and one declared 'static const'?
int main()
{
static const int i1(0);
const int i2(0);
return 0;
}
In one of my compilers, there was a huge difference between
a static const and a const as far as an array went.
With the static const array declaration, the compiler knows
that there is only one instance and can optimize away. With
the const array declaration, the compiler was actually copying
the const data to a temporary local variable that it created.
Since these are integers, the above point may be moot. Your
best bet is to look at the assembly language generated by
the compiler and see what the difference really is.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book