Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!netcom!sjsumcs!horstman From: horstman@mathcs.sjsu.edu (Cay Horstmann) Newsgroups: comp.lang.c++ Subject: Re: Why no renew Message-ID: <1991Mar21.164455.20430@mathcs.sjsu.edu> Date: 21 Mar 91 16:44:55 GMT References: <184@heurikon.heurikon.com> <1991Mar16.172814.6525@mathcs.sjsu.edu> <12194@pasteur.Berkeley.EDU> Organization: San Jose State University - Math/CS Dept. Lines: 36 In article <12194@pasteur.Berkeley.EDU> jbuck@galileo.berkeley.edu (Joe Buck) writes: >In article <1991Mar16.172814.6525@mathcs.sjsu.edu>, horstman@mathcs.sjsu.edu (Cay Horstmann) writes: >|> In article <184@heurikon.heurikon.com> daves@ex.heurikon.com (Dave Scidmore) writes: >|> > 1) Zeroing is infrequently needed and seldom even helpful. >|> >|> Huh? When you say X** a = new X*[100], isn't it most likely that you want >|> all those X*'s to be null pointers? > >What about when you say > >void func() { > X* arrayOfPointers[100]; > ... >} > >Wouldn't you want the pointers to be initialized in this case as >well? What you're really proposing sounds like specifying a >default constructor for non-class types (i.e. pointers get 0, >doubles get 0.0, chars get '\0', etc). This has some advantages, >but I would hope there'd be a way of turning it off for cases where >it's wasteful. > > Joe, I wouldn't argue against that but I am not about to propose it myself. I like to live in peace. There is a reason why I am asking that operator new initialize arrays. If you write a template class for variable size arrays (of ints, char*, X,...) it would be desirable to rely on initialization in all cases since there is (at least with the current template syntax) no way of differentiating between class- and non-class types ("#if isclass(X)...") But in the case of a fixed array inside a single class, I guess one can have that class's constructor do the initialization. Cay