Topic: Q: private static data definition
Author: bgb@pspd51.ATT.COM (nq4120c00-Beuning)
Date: 1995/07/18 Raw View
I have a question about the draft ANSI C++ standard.
What is the proper handling of code like this?
class A {
private:
enum { B = 10 };
static int c[ B ];
};
int A::c[ B ];
I tried it with three compiler and got these results:
1. cfront 3.0.3, accepts it
2. g++ 2.6.3, accepts it
3. Sun Pro 3.0.1, rejects it saying 'B' is not accessible
in the definition of A::c.
The only section in the Draft ANSI C++ document I could find
that applied to this was section 9.3 [Scoping rules for classes]
which from my reading sounds like the above code should be
rejected. The text is:
"The scope of a name declared in a class consists not
only of the declarative region following the name's
declarator, but also of all function bodies, default
arguments, and constructor initializers in that class
(including such things as nested classes)."
Whats the use of being able to declare data private if we need
to make the dimensions of the array public to be able to define
the array??
Thanks,
Brian Beuning
b.beuning@att.com