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

I have One image (means a group photo ) how to split the faces only from the image?............ please send the answer nagadurgaraju@gmail.com thanks in advace...

0 Answers  


what is the use of template classes in c++

1 Answers  


Pls...could any one tell me that whether we can access the public data memeber of a class from another class with in the same program. Awaiting for your response Thanku

4 Answers  


Why polymorphism is used in oops?

0 Answers  


What are the important components of cohesion?

0 Answers  


Why do we use encapsulation in oops?

0 Answers  


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

0 Answers  


What is object in oop?

0 Answers  


is java purely oop Language?

49 Answers   HCL, Infosys, TCS,


what is different between oops and c++

0 Answers   IIT,


What is cohesion in oop?

0 Answers  


what is graphics

0 Answers  


Categories