home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 18002 < prev    next >
Encoding:
Text File  |  1992-12-15  |  1.4 KB  |  41 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!polstra!jdp
  3. From: jdp@polstra.uucp (John Polstra)
  4. Subject: Re: Initialization {} of Aggregates with Static Members
  5. Message-ID: <BzB888.DKA@polstra.uucp>
  6. Organization: Polstra & Co., Inc., Seattle, WA
  7. References: <BzA5oG.Bwu@polstra.uucp> <1992Dec15.094709.5566@eua.ericsson.se>
  8. Date: Tue, 15 Dec 1992 16:52:56 GMT
  9. Lines: 30
  10.  
  11. In article <1992Dec15.094709.5566@eua.ericsson.se> euamts@eua.ericsson.se writes:
  12. > class testbase 
  13. > {
  14. >    public:
  15. >       int y;               // If I remove this line...
  16. > };
  17. > class test : public testbase 
  18. > {
  19. >    public:
  20. >       int myVal;
  21. >       const test* myNext;
  22. > };
  23. > const test t1 = {7,1,0};      // If I remove "7,"
  24. >
  25. > [Remainder of program and description of symptoms deleted]
  26.  
  27. I don't think the above is legal.  ARM section 8.4.1 says that
  28. curly-brace initialization may be used for *aggregates*, and that an
  29. *aggregate* (by definition) has no base classes.  Your class "test" has a
  30. base class, thus it is not an aggregate, thus it may not be initialized
  31. using curly braces.
  32.  
  33. At least, that's my reading of the ARM.
  34. -- 
  35.    John Polstra                              polstra!jdp@uunet.uu.net
  36.    John D. Polstra & Co., Inc.                  ...!uunet!polstra!jdp
  37.    Seattle, Washington USA   Phone (206) 932-6482, FAX (206) 935-1262
  38.    "Self-knowledge is always bad news."                 -- John Barth
  39.