blob: 57df58a067bfdb28d50f2491792cac0130a39853 (
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
90
91
92
93
94
95
96
97
98
99
100
101
102
|
<html>
<head>
<title>STRUCT keyword</title>
</head>
<body>
<font color=brown>
<hr>
<h1>
<center>struct keyword in C++</center>
</h1>
<hr>
<p>
The <b>struct</b> keyword was introduced in 'C', its original functionality
is documented
<a href=../../C/SYNTAX/struct.html>here.</a>
<p>
C++ has added two new features to structures.
<ol>
<li>The syntax has been improved slightly so you no longer have to
mess around with <a href=../../C/SYNTAX/typedef.html>typedef</a> statements.
<p>
<center>
<table border=1 width="80%" bgcolor="ivory">
<tr><td align=center>
<h3>ANSI C approch to structures.</h3>
</tr></td>
<tr><td>
<pre>
typedef struct Person {int age; char *name} Person_t;
struct Person FirstMan;
Person_t SecondMan;
</pre>
</td></tr></table>
<p>
<p>
<table border=1 width="80%" bgcolor="ivory">
<tr><td align=center>
<h3>C++ structures.</h3>
</tr></td>
<tr><td>
<pre>
struct Person {int age; char *name};
Person FirstMan;
Person SecondMan;
</pre>
</td></tr></table>
</center>
<p>
<li>C++ also took the original idea of structures and added the ability to
associate functions with the data within the structure. This feature
was wrapped up with the introduction of the
<a href="class.html">class</a> keyword.
</ol>
<p>
<hr>
<h2>Examples:</h2>
<img src="../../GRAPHICS/computer.gif">
<a href="../EXAMPLES/struct1.cc">Example program.</a>
<p>
<hr>
<h2>See Also:</h2>
<img src="../../GRAPHICS/whiteball.gif" alt="o">
<a href="keywords.html">C++ Keywords</a>
<br>
<img src="../../GRAPHICS/whiteball.gif" alt="o">
<a href="../../C/SYNTAX/keywords.html">C Keywords</a>
<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
12 Nov 98</address><p>
</font>
</body>
</html>
|