What is meant byStatic Variable ?

Answer Posted / rutuja gaikwad

static variable is a variable which declared inside class
using keyword static.
its value used only in that class not overall program


example:


#include <stdio.h>

void func() {
static int x = 0; // x is initialized only once
across three calls of func()
printf("%d\n", x); // outputs the value of x
x = x + 1;
}

int main(int argc, char * const argv[]) {
func(); // prints 0
func(); // prints 1
func(); // prints 2
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why did you ever become involved in QA/testing?

1801


Difference between HTML and DHTML?

1861


how CLR identify vb file?

2713


Where do we need Operator overloading?

857


what is an INI file?

1849


Given a set. Write the pseudo code to get all the subsets for the given set. Eg. Input : {1,2} Output : (),(1),(2),(1,2)

2443


Definition of Singleton Class? what is the Purpose of it? what is the advantage?

1837


When you deliver your C++ headers and C++ library of a class (what all can you change in the class so that application using your class does not need to recompile the code)

930


9.Difference between even and odd signals?explain with the diagram?

3151


what are the advantages of sap on other software ?

1917


how to stop execution of step 3 in a job mainframe

1901


Difference between views and index in sas programming

1223


< DL Compact > tag is used for

1737


1.how to deploy the Maven application in weblogic server? 2.In Real time projects all classes are singleton or some classes only singleton explain? 3.what are the major uses of the designpatterns? 4.explain restful &Soap based services explain?

1856


Hey this is venkatesh.Please can any body tell me what is SFLNXTCHG?where we use this keyword?what perpuse we use this?Can you tell me in real time senario with example? And in 7 specification(RPG/400)what is the mandatory specification using programs?

1745