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 correct syntax for inheritance? 1) class aclass : public superclass 2) class aclass inherit superclass 3) class aclass <-superclass

6 Answers   Wipro,


What is the expansion of OOPS?

24 Answers   TCS,


write a program to find 2^n+1 ?

0 Answers   CTS,


How can we use the preprocessor #if and #elseif.

2 Answers  


What is the difference between class and object?

4 Answers   Apple, Heinz,






me get an assignent n its question is this 1.creat a set as in math i.ea={1,2} 2.insert element in it3. delete element don,t repeat any element 4.union 5. intersection of two sets plz help me i always pray for u n send me at ayeshawzd@hotmail.com f u have c++ how to program 5th addition then it is the 10.9 question in 10th chapter exercise

1 Answers  


Why many objects can working together? How objects working togetherM I want to see example code.

2 Answers  


Child cObj = new Parent() Wahts the output ?

8 Answers   Patni, TCS,


3. Differentiate verification and validation.

1 Answers  


Why is abstraction used?

0 Answers  


Why is it so that we can have virtual constructors but we cannot have virtual destructors?

2 Answers  


The company is a fake company asking for money of RS10000 while training and not offering a job after training. My humble request to you people not to attend Astersys interview

1 Answers   Astersys,


Categories