INTERVIEW QUESTIONS
C
VARIABLES IN C
DETAILS
Question: Can static variables be declared in a header file?
Answer: Yes there is difference between declaring a static variable as global and local. If it is local, it can be accessed only in the function where it's declared. But if it is global, all functions can access it. But, what ever be the case, its value will be retained between functions.
|
Question:
Can static variables be declared in a header file?
Answer:
Yes there is difference between declaring a static variable as global and local. If it is local, it can be accessed only in the function where it's declared. But if it is global, all functions can access it. But, what ever be the case, its value will be retained between functions. Source: CoolInterview.com
Yes there is difference between declaring a static variable as global and local. If it is local, it can be accessed only in the function where it's declared. But if it is global, all functions can access it. But, what ever be the case, its value will be retained between functions but it can't be accessed by any function that not belong to that file in static variable is declared is globally. Source: CoolInterview.com
Answered by: Dheeraj Sharma | Date: 1/16/2008
| Contact Dheeraj Sharma
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|