Path: utzoo!utgpu!attcan!uunet!husc6!mailrus!purdue!decwrl!ie0013.dec.com!vilot From: vilot@ie0013.dec.com (Michael J. Vilot) Newsgroups: comp.lang.c++ Subject: Re: using references vrs. pointers Message-ID: <8901271426.AA26362@decwrl.dec.com> Date: 27 Jan 89 17:28:00 GMT Organization: Digital Equipment Corporation Lines: 29 > However, I seem to have no way of initializing > a reference to refer to nothing, or testing if it refers to nothing (akin > to a pointer to NULL). Any reference must be initialized ("The C++ Programming Language", p. 56). You can borrow a trick from Ada programmers: define a null object for any class where such an object is sensible. The you can declare references as alternate names for it: class foo { int value; // ... public: foo(); foo(foo&); // X(X&) initializer // ... }; foo NULL_FOO; f() { foo& bar = NULL_FOO; } Hope this helps, Mike Vilot Self-employed. Consulting at: e-mail: vilot%csdpie.dec@decwrl.dec.com when that fails: (508)467-3631 [for now]