home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11520 < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.8 KB  |  51 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mole-end!mat
  3. From: mat@uunet.uu.net!mole-end
  4. Subject: Re: Q: static members and private constructors
  5. Message-ID: <1992Jul25.070732.4066@uunet.uu.net!mole-end>
  6. Summary: A bug, actually
  7. Organization: :
  8. References: <YDD5OTF@hp832.informatik.hu-berlin.de> <18607@drutx.ATT.COM>
  9. Date: Sat, 25 Jul 1992 07:07:32 GMT
  10. Lines: 39
  11.  
  12. In article <18607@drutx.ATT.COM>, weh@abasin.dr.att.com (William E. Hopkins) writes:
  13. > In article <YDD5OTF@hp832.informatik.hu-berlin.de>, loewis@informatik.hu-berlin.de (M.v.Loewis) writes:
  14.  
  15. > |> In the following program, it is not possible to create static (class)
  16. > |> instances of a class with only private constructors. I suppose it is
  17. > |> a general compiler error:
  18.  
  19. > |> A B::m(1);
  20.  
  21. > |> The problem is the last statement: I think it should be possible to create
  22. > |> the m member of B somehow, since B is a friend of A, but all compilers I 
  23. > |> tried complained ...
  24.  
  25. > "static.c", line 21: error: global scope cannot access A:A(): private member
  26.  
  27. > The Annotated C++ Reference Manual (ARM) is not explicit on this subject,
  28. > but a sentence in section 9.4 ``Static Members'' is relevant ...
  29.  
  30. >     Static members of a global class are initialized exactly like
  31. >     global objects and only in file scope.
  32.  
  33. > Thus, the initialization of B::m takes place in file scope, which does not
  34. > have access to the private parts of A.
  35.  
  36. > It is not a bug; it is a feature.  ...
  37.  
  38. Actually a bug in the ARM.  This will probably be changed in the final
  39. ANSI/ISO standard, since it was long ago changed in the working paper.
  40. The initialization effectively takes place in the class scope.
  41.  
  42. > ... attempting to get changes considered by the ANSI C++ committee...
  43. > Good luck!
  44.  
  45. Done!
  46. -- 
  47.  (This man's opinions are his own.)
  48.  From mole-end                Mark Terribile
  49.  
  50.  uunet!mole-end!mat, Somewhere in Matawan, NJ
  51.