Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!arisia!sgi!shinobu!odin!rhialto!andru From: andru@rhialto.sgi.com (Andrew Myers) Newsgroups: comp.lang.pascal Subject: Re: experience with tp5.5? Message-ID: <235@odin.SGI.COM> Date: 24 Jul 89 21:10:15 GMT References: <799@eutrc3.urc.tue.nl> <390004@hpctdls.HP.COM> <2971@internal.Apple.COM> <317@maytag.waterloo.edu> Sender: news@odin.SGI.COM Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 31 In article <317@maytag.waterloo.edu> dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes: > >In TP 5.5, you're allowed multiple constructors in a single object, presumably >to allow it to be initialized in different ways depending on the circumstances. >You're also allowed to pass parameters to the constructor, and the different >constructors don't need to take the same parameters. Both of these mean >the constructor can't be called automatically. > >Isn't this a problem in C++? > >Duncan Murdoch No, it isn't. You can't create an object in C++ without calling a constructor method. To pass arguments to the constructor which requires them, you specify them when you declare the object, e.g. IntegerArray foo(5); Where a constructor IntegerArray::IntegerArray(int length); exists. If a class has a superclass with different constructor argument requirements, this can be handled as well: RawData::RawData(long bytes); IntegerArray::IntegerArray(int length) : (long(length * sizeof(int))) { ... } Andrew