3.1 C

Let us reuse the same example as in the constructor example.

struct X
{
  int i;
  float f;
  char a[20];
};

Now, let us consider the use of a variable of struct X type.

{
  struct X myX;

  // ... code to initialize and use myX
}

At the end of this block of code, nothing special happens. The storage that belongs to myX is ``deallocated'', but nothing else happens. If there is any clean up to perform, that clean up code needs to be invoked explicitly, like the following:

{
  struct X myX;

  // ... code to initialize and use myX
  X_cleanup(&myX);
}

It is a bit too early to discuss the kind of clean-up code that a program may need to perform.



Copyright © 2006-09-05 by Tak Auyeung