what is a ststic variable and stiticfunction
briefly explain with exmple and in which case we use

Answers were Sorted based on User's Feedback



what is a ststic variable and stiticfunction briefly explain with exmple and in whic..

Answer / subhashish sen

When a variable is declared with static keyword,its called
as static variable,means it retains its value across
different function calls.Its basically used for counting no
of objects created for a class in C++ and its initialized to
0 by default.

When a function declared as static,its called as static
function.It can only operate on static variables.

Is This Answer Correct ?    3 Yes 1 No

what is a ststic variable and stiticfunction briefly explain with exmple and in whic..

Answer / zubeir

Static variable is the one allocated statically, meaning
that, it is allocated once in the program space and exists
till the program space is deallocated (the close of the
application).

Note:- Some people get confused between stack allocation
and static allocaion. Both are different terms.

A static function is again the same concept with static
variable allocation, but here the allocation is not just a
variable but a function's 'activation frame'. The
activation frame, for now, consider the function's
information required by the compiler to execute the
function which is stored internally.

Is This Answer Correct ?    1 Yes 5 No

Post New Answer

More OOPS Interview Questions

polymorphism means?

6 Answers   BFL,


what is the difference between javap and jad utility

1 Answers   Wipro,


function overridind means and simple program

2 Answers  


C#.net Interview Question A=10 B=5 C=A+B Print C The above will be given in a multiline textbox. You need to parse the above input, store values for A,B&c. And you have to display the value of C.

1 Answers   Syncfusion,


How do you define social class?

0 Answers  


What are the different forms of polymorphism??

8 Answers   Mantaq, NUC, PCS,


what isthe difference between c structure and c++ class

5 Answers  


Why it is called runtime polymorphism?

0 Answers  


Can we have a private constructor ?

12 Answers   HSBC, Ness Technologies, TCS, Wipro,


why in java first invoke public static void main(String args[]) method????Why not public static void method1(String args[])??

1 Answers  


write a c++ code of diagonal matrix.

2 Answers  


What is static modifier?

0 Answers  


Categories