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

What Is a Polymorphism? How many types of polymorphism and whats that use in application?

2 Answers  


What is oop in simple words?

1 Answers  


What is polymorphism and why is it important?

0 Answers  


When is a memory allocated to a class?

11 Answers  


what is the use of template classes in c++

1 Answers  






Why we use classes in oop?

0 Answers  


Explain the concept of abstracion and encapsulation with one example. What is the difference between them?

3 Answers   PCS,


c++ is a pure object oriented programming or not?

5 Answers   Wipro,


what is ns string? what is ns array?

1 Answers  


what does exactly the linker do?

1 Answers  


What does sksksk mean in text slang?

0 Answers  


What is multilevel inheritance in oop?

0 Answers  


Categories