Bloomberg LP Interview Question
Software Engineer / DevelopersSay that you have a
File called _test_static and
function (static void foo) inside this file.
WITHOUT the word static at the beginning of the function declaration, the function becomes a global function. If any file #includes _test_static, It can not call the function. So basically the static keyword makes it visible only within _test_static file. Hope that helps.
Yes.. at the expense of being pedantic, its called "internal linkage". So, non static functions will have external linkage. This concept is implemented both in C & in C++. Regardless of whether a function name has internal or external linkage, it has File scope (assuming its declared outside all blocks).
I dont understand why one needs a static method in C. I have heard of static variables in a method. But not a static method itself. Could you please let me know what it is.
- srihari January 10, 2006