next up previous contents
Next: Do not Be Too Up: Software Development and Coding Previous: Reference Counting   Contents

Multiple Constructors in a Class

When you have multiple constructors in a class, write a single method called construct() that initializes all of your member variables. Then in each constructor, call construct() on the first line.


24#24

This way if you add new member variables, you only need to update one function rather than going to each constructor and figuring out what to do. This greatly reduces the chance of forgetting a constructor or a member variable.



Falko Kuester 2001-08-24