what do you mean by static member variable?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why polymorphism is used in oops?

777


What does I oop mean?

819


What is the real life example of polymorphism?

841


Whats oop mean?

774


What is the purpose of polymorphism?

864


What is static in oop?

818


Why is abstraction used?

826


what is the drawback of classical methods in oops?

3104


What is the advantage of oop over procedural language?

835


given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy

2356


What is class encapsulation?

808


Why is it so that we can have virtual constructors but we cannot have virtual destructors?

4308


Why multiple inheritance is not possible?

780


What is cohesion in oop?

832


What is balance factor?

803