what do you mean by static member variable?

Answers were Sorted based on User's Feedback



what do you mean by static member variable?..

Answer / madhu

In C++ when you declare and define a static variable, it
tells the compiler that only one copy of memory will be
allocated and all the objects of that class will share that
copy.
As we know for class data variables memory will be created
independently for every object of that class. and we can
access the data using object. But, for static variables
memory is created only once for all objects and is no object
is owned the static variable. we can access the static
variable using class name.

Mainly static variables are used when want to count the
objects created and destroyed and when we are dealing with
singleton design pattern.

Is This Answer Correct ?    10 Yes 0 No

what do you mean by static member variable?..

Answer / bhaskar

when static member variable executed that variable value is
automatically assigns to zero....

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More OOPS Interview Questions

What is the types of inheritance?

0 Answers  


Why is object oriented programming so hard?

0 Answers  


What are the 3 principles of oop?

0 Answers  


polymorphism means?

6 Answers   BFL,


1. Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)

1 Answers   Nagarro,






Iam doing my project on instant messaging , if you any new ideas regarding this project ,please suggest it?

2 Answers  


Tell us about yourself.

47 Answers   ABB, Amazon, Fidelity, Flextronics, Franklin Templeton, HCL, Hexaware, IBM, Impetus, Infosys, Reliance, Rofous, Silgate, Sutherland, TCS, Thomson Reuters, Virtusa, Wipro,


wht is major diff b/w c and c++?

10 Answers  


What are the benefits of polymorphism?

0 Answers  


Why is destructor used?

0 Answers  


What is encapsulation with example?

0 Answers  


How oops is better than procedural?

0 Answers  


Categories