summaryrefslogtreecommitdiff
path: root/reference/CPLUSPLUS/SYNTAX/static.htm
blob: a3be4401da14388345e94b45f0baaaa08ae7a076 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

<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>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="../../C/FUNCTIONS/funcref.htm">Functions</a>
</td>
</tr>
</table>
</center>
<p>
 
<hr>
<address>Martin Leslie
08-Dec-96</address>