Information Technology Reference
In-Depth Information
Data Members and Function Members
Some types, such as
short
,
int
, and
long
, are called
simple types
, and can only store a single
data item.
Other types can store multiple data items. An
array
, for example, is a type that can store
multiple items of the same type. The individual items are called elements, and they are refer-
enced by a number, called an
index
. Arrays will be looked at in detail in Chapter 14.
Types of Members
Other types, however, can contain data items of many different types. The individual elements
in these types are called
members
, and, unlike arrays, in which each member is referred to by a
number, these members have distinct names.
There are two types of members: data members and function members.
Data members
store data that is relevant to the object of the class or to the class itself.
Function members
execute code. Function members define how the type can act.
For example, Figure 3-3 shows some of the data members and function members of type
XYZ
. It contains two data members and two function members.
Figure 3-3.
Types specify data members and function members.