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

difference between structure and union.

2 Answers   ADP, Convergys,


In OverLoading concept,Why they are not consider return value and why they are consider only parameters in method? For ex: public int Add(int a,int b){...} public String Add(int a,int b){...}

1 Answers  


write a c++ program to find maximum of two numbers using inline functions.

3 Answers   IBM,


In what situation factory design patterns,DAO design patterns,singleton design patterns should be applied.?

2 Answers  


Polymorphism with an example?

8 Answers   Accenture, emc2,






How is data security provided in Object Oriented languages? ?

5 Answers  


What is difference between #define and const?

3 Answers   emc2,


The type of variable a pointer points to must be the part of pointer's definition so that:

1 Answers   Infosys,


What is static modifier?

0 Answers  


Which method cannot be overridden?

0 Answers  


What are constructors in oop?

0 Answers  


What is destructor oops?

0 Answers  


Categories