3.2 ADT details

In order to support the features describe in the previous section, it is best to use an ADT architecture. Let us describe this architecture in a bottom up fashion.

Data member definition. A data member definition describes a data member in a record type. It has the following interface:

Record type. A record type is analogous to a named struct in C, or a class in C++ without methods. It has the following interface:

Data member. A data member is a part of a record (instance). A data member has a particular value, and it must correspond to a data member definition. Its interface is as follows:

Record (instance). A record (instance) is an actual record with its own state. It has the following interface:

To make things a little easier to understand, here is an example using the built-in struct construct in C.

struct X // record type, name is X
{
  int i; // data member defn, name is i, type is int
  float f; // data member defn, name is f, type is float
};

{
  X myX; // record (instance) myX
  myX.i = 0; // record->setDataMember
  printf("%f\n",myX.f); // record->getDataMember
}

Copyright © 2006-09-13 by Tak Auyeung