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 the different between Applet and Application?

2 Answers  


What causes polymorphism?

0 Answers  


#include <iostream> using namespace std; struct wow { int x; }; int main() { wow a; a.x = 22; int c = a.x; int *b = new int; cout << c; return 0; } option: No output 0 22 -(11) Will not compile

1 Answers   CTS, Wipro,


What is inheritance in oop?

0 Answers  


hi all..i want to know oops concepts clearly can any1 explain??

0 Answers   Eureka Forbes,






What is polymorphism in oop example?

0 Answers  


What is the real time example of inheritance?

0 Answers  


what do you mean by static member variable?

2 Answers  


What does I oop mean?

0 Answers  


What is overriding in oops?

0 Answers  


4. What do you mean by a prototype? Define analysis prototype

1 Answers  


What does the code "cout<<(0==0);" print? 1) 0 2) 1 3) Compiler error: Lvalue required

15 Answers   ISTS, Wipro,


Categories