WWC snapshot of http://www.alw.nih.gov/Docs/NIHCL/nihcl_27.html taken on Sat Jun 10 19:13:49 1995

Go to the previous, next section.

Nil--The Nil Object

SYNOPSIS

#include <nihcl/Object.h>

BASE CLASS

Object

DERIVED CLASSES

None

RELATED CLASSES

None

DESCRIPTION

There is but a single instance of class Nil, which is accessible via a public static pointer member variable Object::nil:

static Object* const nil;

Pointers to the Nil object are used as placeholders by container classes such as Set and ArrayOb, and sometimes as a "failure" return object from functions that perform a search, for example.

The advantage of using a pointer to the Nil object rather than a 0 (or NULL) pointer is that applying a member function to a 0 pointer is an error. To avoid this, it is necessary to check that a pointer is non-zero before applying a member function to the object it references. However, using a pointer to the Nil object eliminates the need for this test.

CONSTRUCTORS

Nil()
Constructs the sole instance of class Nil. This constructor is not accessible to library users.

SEARCHING

virtual unsigned hash() const
Returns 0.

COMPARING THE NIL OBJECT

virtual int compare(const Object& ob) const
Returns 0 (equal) if ob is the nil object; otherwise, raises an NIHCL_BADARGSPM exception.

TESTING THE NIL OBJECT

virtual bool isEqual(const Object& ob) const;
Returns YES if ob is the Nil object.

COPYING THE NIL OBJECT

virtual Object* copy() const
Returns a pointer to the Nil object.

READING AND PRINTING THE NIL OBJECT

virtual void dumpOn(ostream& strm =cerr) const
virtual void printOn(ostream& strm =cout) const
Prints "NIL" on the output stream strm.

DISABLED MEMBER FUNCTIONS

virtual void deepenShallowCopy()
virtual void storer(OIOout&) const
virtual void storer(OIOofd&) const
These functions are implemented as shouldNotImplement().

EXCEPTIONS RAISED

NIHCL_BADARGSPM

Go to the previous, next section.