Interview Question for C++ enthusiasts: Question: What is the significance of static keyword in C/C++ ? Answer: In C/C++, static keyword has an overloaded meaning and is used in 3 different contexts: a. When used before global functions, they limit the scope to the current file (heavily used in C) b. When used inside a function, it indicates that the variable is of local scope but of static lifetime( meaning that the value remains between function calls) c. When used for member within a class, it indicates that they are class members( we can directly access the members using scope resolution operator with the syntax classname::static member).
Posted on: Fri, 21 Nov 2014 06:30:00 +0000
Trending Topics
Recently Viewed Topics
© 2015