home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18632 < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.4 KB  |  47 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!demos!news-server
  3. From:  stas@itco.msk.su (Stas Strizhakov)
  4. Subject: Re: New try: Access to private constructor for building a private static member
  5. Date: Thu, 31 Dec 1992 06:52:14 GMT
  6. Reply-To: stas@itco.msk.su
  7. Organization: I.T. Co., Moscow, Russia.
  8. Sender: news-server@kremvax.hq.demos.su
  9. Message-ID: <ABUYfGheZA@itco.msk.su>
  10. Lines: 35
  11.  
  12. In message <GIROD.92Dec23081920@node_262d6.tele.nokia.fi>
  13. Subject: [NEWS] New try: Access to private constructor for building a private static member
  14. girod@tele.nokia.fi (Marc Girod) writes:
  15.  
  16. >class A {
  17. >  private:
  18. >    A();
  19. >    static A a;
  20. >};
  21. ...
  22. >Are my compilers correct in refusing me the access to private
  23. >constructors, to build a private static member?
  24.  
  25. Yes, it is correct, because private member functions, including constructors,
  26. can't be used out from class instance because of unvisibility. It is
  27. ideology of OOP. If you try to create private static member with private
  28. constructor, compiler will consider this as try to access private member
  29. function out from instance during startup code.
  30. So you should make the constructor with "public" access declaration.
  31.  
  32. I think so.
  33. --
  34.  
  35.                     Regards,
  36.                                 Stas.
  37. ???????????????????????????????????????????????????????????????????????????????
  38.                         There's so many different worlds
  39.                         So many different suns
  40. Stas K. Strizhakov                I.T.Co                Programmer
  41. phone    : (7-095)262-4381        fax     : (7-095)924-3775
  42. e-mail    : stas@itco.msk.su
  43.  
  44.  
  45.  
  46.  
  47.