Static variable in a class is initialized when first object of the class is created - C++ basic concepts

Q.  Static variable in a class is initialized when _____ .
- Published on 17 Jul 15

a. every object of the class is created.
b. last object of the class is created.
c. first object of the class is created.
d. No need to initialize static variable.

ANSWER: first object of the class is created.
 

    Discussion

  • Brijesh   -Posted on 13 Oct 15
    All static data is initialized when the first object is created. Static members exist as members of the class not as an instance of the class. If you declare a function as static then this keyword is not available in a static member function.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)