The word STATIC has two meanings in C The meaning of the re
The word STATIC has two meanings in C:
- The meaning of the reserved word static depends on the context of its appearance. If used on the definition of a variable inside a function, it means the variable is created at compile time.
- If used on the definition of a variable that is outside all functions, it means the variable is visible only in the file in which its definition appears; that is, it is not exported from that file.
QUESTION: What other meanings are there for STATIC in C++?
WRONG ANSWER = REPORTED AND DOWNVOTED.
Solution
Meaning of static in C++ are:
Static variable in functions
Static Class Objects
Static member Variable in class
Static Methods in class
Static variable in functions : Static variables when used inside function are initialized only once, and then they hold there value even through function calls.
Static Class Objects : Static keyword works in the same way for class objects too. Objects declared static are allocated storage in static storage area, and have scope till the end of program.Static objects are also initialized using constructors like other normal objects. Assignment to zero, on using static keyword is only for primitive datatypes, not for user defined datatypes.
Static member Variable in class : Static data members of class are those members which are shared by all the objects. Static data member has a single piece of storage, and is not available as separate copy with each object, like other non-static data members.Static member variables (data members) are not initialied using constructor, because these are not dependent on object initialization.
Static Methods in class : These functions work for the class as whole rather than for a particular object of a class.It can be called using an object and the direct member access . operator. But, its more typical to call a static member function by itself, using class name and scope resolution :: operator.
