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
What is the real time example of inheritance?
What is polymorphism and its types?
What is meant by oops concept?
What is abstraction and encapsulation?
What are the 3 pillars of oop?
hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.
Why is polymorphism important in oop?
What is class in oop with example?
What is data binding in oops?
What is the important feature of inheritance?
Why is oop useful?
What is encapsulation in ict?
What is encapsulation in simple terms?
What does it mean when someone says I oop?
What type of loop is a for loop?