Topic: Constructor initialization


Author: Michael Spertus <mps@geodesic.com>
Date: 1996/06/07
Raw View
It should be possible to use a class as a base class of
itself for the purpose of member initialization, allowing one
constructor to delegate to another constructor:

class A {
 A(foo);
 A(Bar b) : A(foo(b)) {}
};

This is very clean and there are many cases where default arguments and
overloading can't provide correct delegation. Furthermore,
because classes are often treated as base classes of themselves already
in the standard (say, for inheritance), it makes the language simpler.

I know this would be very useful in my code, and I can't think of a
single
disadvantage. What does everyone think?

Mike

Michael Spertus
Geodesic Systems
4745 N. Ravenswood, Suite 111
Chicago, IL 60640

mps@geodesic.com
(312) 728-7196
http://www.geodesic.com


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]