|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Accessibility of a static constant within a class
Consider the following code paying attention to the
comments:
class foo {
public:
static const int TEXT_SIZE = 255; // TEXT_SIZE is
accessible within eggs.
void bar() {
size = TEXT_SIZE;
}
private:
// static const int TEXT_SIZE = 255; is not accessible
within struct eggs.
struct eggs {
// char buffer2[foo::TEXT_SIZE]; does not work.
char buffer2[TEXT_SIZE];
};
char buffer[TEXT_SIZE]; // Public or private TEXT_SIZE
are both accessible.
int size;
};
Why is TEXT_SIZE not accessible within the struct eggs
declaration if TEXT_SIZE is declared to be private?
The declaration of the buffer array and the bar function
have no problem with TEXT_SIZE being private but eggs can
only access TEXT_SIZE if its declared to be public.
- Edward
Oct 24 2006
"Edward A. Waugh" <edward_waugh hotmail.com> wrote in message news:ehlo0k$1vfl$1 digitaldaemon.com... Oct 24 2006
|