InterviewSolution
Saved Bookmarks
| 1. |
Is it possible to declare a static variable in a header file? |
|
Answer» Variables defined with static are initialized once and persists until the end of the program and are local only to the block it is defined. A static variables declaration REQUIRES definition. It can be defined in a header file. But if we do so, a private COPY of the variable of the header file will be present in each source file the header is INCLUDED. This is not preferred and HENCE it is not recommended to use static variables in a header file. |
|