Hi all,
1) I had few questions regarding C++ static keyword. Is there any difference in scope between a in following two code snippets?
Code://myfunc.h const int a = 1; int main(...) { ... }2) What about the similar situation with the variables replaced by functions? Would static keyword make any difference in scope?Code://myfunc.h const static int a = 1; int main(...) { ... }
3) I also heard that in comparing declaring a const variable within any function versus declaring a static const variable in global scope, the latter is more efficient because it avoides stack allocation. Is it ture, and if so, where is the value stored?
I tried to look it up in a C++ reference book I have, but I couldn't find it there or online. I'd appreciate for any pointers. Thanks!



LinkBack URL
About LinkBacks



