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
Why polymorphism is used in oops?
What does I oop mean?
What is the real life example of polymorphism?
Whats oop mean?
What is the purpose of polymorphism?
What is static in oop?
Why is abstraction used?
what is the drawback of classical methods in oops?
What is the advantage of oop over procedural language?
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
What is class encapsulation?
Why is it so that we can have virtual constructors but we cannot have virtual destructors?
Why multiple inheritance is not possible?
What is cohesion in oop?
What is balance factor?