Topic: ISO C++ Draft 28/5/95: query on 12.6.1 (Explicit Initialization)


Author: pgr@sst.icl.co.uk (Phil Richards)
Date: 1995/05/30
Raw View
In 12.6.1, paragraph 2, final example, it shows:

 class X {
  int i;
  float f;
  complex c;
 } x = { 99, 88.8, 77.7 };

and describes how each of the members are initialized.  My question is:

Is this valid considering i, f, and c are all private?  Is this just
a typo (missing public:, or should be a struct), or have I missed something
somewhere else?

I would assume that the form:

 class X {
  int i;
  float f;
  complex c;
 };

 X x = { 99, 88.8, 77.7 };

*is* invalid (otherwise private: seems to be meaningless); if it isn't a
typo, is the previous form a special case?

Phil
--
Not speaking for ICL





Author: jsa@edg.com (J. Stephen Adamczyk)
Date: 1995/05/30
Raw View
In article <pgr.084602.30May95@sst.icl.co.uk> pgr@sst.icl.co.uk (Phil Richards) writes:
>In 12.6.1, paragraph 2, final example, it shows:
>
> class X {
>  int i;
>  float f;
>  complex c;
> } x = { 99, 88.8, 77.7 };
>
>and describes how each of the members are initialized.  My question is:
>
>Is this valid considering i, f, and c are all private?  Is this just
>a typo (missing public:, or should be a struct), or have I missed something
>somewhere else?

You are correct.  The presence of private nonstatic data members makes this
class not an aggregate (8.5.1), and therefore brace-enclosed initialization
is not allowed.  I'll pass this on to the proper person to get it updated.

Steve Adamczyk
Edison Design Group