home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mole-end!mat
- From: mat@uunet.uu.net!mole-end
- Subject: Re: Q: static members and private constructors
- Message-ID: <1992Jul25.070732.4066@uunet.uu.net!mole-end>
- Summary: A bug, actually
- Organization: :
- References: <YDD5OTF@hp832.informatik.hu-berlin.de> <18607@drutx.ATT.COM>
- Date: Sat, 25 Jul 1992 07:07:32 GMT
- Lines: 39
-
- In article <18607@drutx.ATT.COM>, weh@abasin.dr.att.com (William E. Hopkins) writes:
- > In article <YDD5OTF@hp832.informatik.hu-berlin.de>, loewis@informatik.hu-berlin.de (M.v.Loewis) writes:
-
- > |> In the following program, it is not possible to create static (class)
- > |> instances of a class with only private constructors. I suppose it is
- > |> a general compiler error:
-
- > |> A B::m(1);
-
- > |> The problem is the last statement: I think it should be possible to create
- > |> the m member of B somehow, since B is a friend of A, but all compilers I
- > |> tried complained ...
-
- > "static.c", line 21: error: global scope cannot access A:A(): private member
-
- > The Annotated C++ Reference Manual (ARM) is not explicit on this subject,
- > but a sentence in section 9.4 ``Static Members'' is relevant ...
-
- > Static members of a global class are initialized exactly like
- > global objects and only in file scope.
-
- > Thus, the initialization of B::m takes place in file scope, which does not
- > have access to the private parts of A.
-
- > It is not a bug; it is a feature. ...
-
- Actually a bug in the ARM. This will probably be changed in the final
- ANSI/ISO standard, since it was long ago changed in the working paper.
- The initialization effectively takes place in the class scope.
-
- > ... attempting to get changes considered by the ANSI C++ committee...
- > Good luck!
-
- Done!
- --
- (This man's opinions are his own.)
- From mole-end Mark Terribile
-
- uunet!mole-end!mat, Somewhere in Matawan, NJ
-