Can static variables be declared in a header file? Ans. 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. - Study24x7
Social learning Network
20 Mar 2023 12:18 PM study24x7 study24x7

Can static variables be declared in a header file? Ans. 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...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles