Answered Questions

  •  Can static variables be declared in a header file?

    You can’t declare a static variable without defining it as well (this is because the storage class modifiers static and extern are mutually exclusive). A static variable can be defined in a header file, but this would cause each source file that included the header file to have its own private copy of the variable, which is probably not what was intended.  

    sssss

    • Nov 11th, 2007

    In CThe scope of static variable is file. ie., if declared the variable is accessible accross the file.When declared the vairable in a header then its exposed to where ever its included.  Every f...

    vg_220

    • Aug 14th, 2007

    We are talking C. Isn't it? C doesn't have class construct so please think the 'C' way ! According me, static declaration in a header file should not generally be useful. Can anyone suggest a good use of it?