Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pyramid.pyramid.com!rvadnais From: rvadnais@pyramid.pyramid.com (VadGuy) Newsgroups: comp.lang.c++ Subject: Re: another Zortech bug? Summary: It's not a bug Keywords: Stroustrup Message-ID: <9002102248.AA09963@polyslo.CalPoly.EDU> Date: 10 Feb 90 22:48:18 GMT References: <4800083@m.cs.uiuc.edu> Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: rvadnais@pyramid.pyramid.com (VadGuy) Distribution: usa Organization: Cal Poly San Luis Obispo Lines: 38 In article <4800083@m.cs.uiuc.edu> rchen@m.cs.uiuc.edu writes: >I'm running Zortech 2.0, and possibly the problem is in the >compiler, but since the details of how to do this don't seem >to be discussed anywhere, I'm not yet ready to point the >finger in Walter's direction. > >The problem is to do with static members in a class, where >the static member is 1) an array; and 2) a user-defined >class with a single constructor which takes no parameters. [specific example of problem deleted] We recently ran into this same problem recently in our C++ class. Here's what my professor had to say about it: From cstaley Wed Feb 7 11:26:37 1990 Here are two fun facts I've learned about C++: ... 2. Buried deep in the innards of Stroustrup is this little rule that says that objects that have a constructor may not be used as static data members of a class. This means that you may not have the associative_array as a static member of Id, even though this would be stylistically correct. I can think of no reason for this dumb rule, but I didn't design the language. I got around this limitation by declaring a null pointer to the associative_array and then calling the constructor explicitly in the constructor for Id when the pointer has a null value. This requires the overhead of a check everytime the constructor for Id is called, but it does the trick. In other words: it's not a bug, it's a feature. :) Hope this helps. --- Bob Vadnais rvadnais@polyslo.CalPoly.EDU "Have a nice day!" (Offer void where prohibited by law)