<head> <title>static keyword</title> </head> <body bgcolor="#cccccc"> <font color=brown> <hr> <center><h1>static keyword</h1></center> <hr> <p> The <b>static</b> keyword has been extended in C++ to have the following meanings. <p> <table bgcolor="ivory" border=2> <th>C++ Context</th> <th>Action</th> <tr> <td> A variable outside of a function. </td> <td> Variable can be seen by all functions in the file. Default. </td> </tr> <tr> <td> Variable inside a function. </td> <td> The variable is permanent. The variable can only be initalised once and only one copy of the variable exists. Recursive calls use the same variable. </td> </tr> <tr> <td> A class member variable </td> <td> Only one copy of the variable exists. All instances of the object use the same variable (memory location). </td> </tr> <tr> <td> A class member function (method). </td> <td> Function can only access static members of the class </td> </tr> </table> <p> <hr> <a href="../../C/SYNTAX/storage_class.html#static">Here is the way static works in C</a> <hr> <h2>Examples:</h2> <img src="../../GRAPHICS/computer.gif"> <a href="../EXAMPLES/static.cc">No example programs yet.</a> <hr> <h2>See Also:</h2> <hr> </font> <font color=black> <h2>C References</h2> <p> <hr> <p> <center> <table border=2 width="80%" bgcolor="ivory"> <tr align=center> <td width="25%"> <a href="../cref.html">Top</a> </td><td width="25%"> <a href="../../C/master_index.html">Master Index</a> </td><td width="25%"> <a href="keywords.html">C++ Keywords</a> </td><td width="25%"> <a href="../../cref/FUNCTIONS/funcref.htm">Functions</a> </td> </tr> </table> </center> <p> <hr> <address><a href="../../address.html">Martin Leslie</a> 08-Dec-96</address>
.