Mail Archives: djgpp/1998/09/22/13:03:16
Horst Kraemer wrote:
> >I get these errors:
>
> >bug1.cc:12: warning: all member functions in class `singelton' are private
> >bug1.cc:12: warning: `class singelton' only defines a private destructor and
> >has no friends bug1.cc: In function `(static destructors for bug1.cc)':
> >bug1.cc:8: `singelton::~singelton()' is private bug1.cc:33: within this
> >context
>
> >Small problem:
> >The warning about all member functions being private and the class having no
> >friends is not useful when there are static instances of the class.
>
> Why ?
OK, I've made a small mistake here. There should be at least one public
member function. I guess the warning is to tell people that they may be
making a potentially useless class. All private constructors and no
friends means that no one can construct the object, however that's not
important if there are static instances of the class inside the class as
they should be constructed anyway.
> >Bug:
> >The static singleton is within the scope of class and should be able to be
> >destructed, but DJGPP is trying to destroy it at global scope.
> >*/
>
> The scope of the declaration has nothing to do with scope of
> "destruction". The scope of "contruction" of singelton::instance is
> the scope of the class by definition. The scope of destruction is the
> scope of the definition - i.e. global scope. The d'tor is not
> accessible at global scope.
So you are saying that a static instance of a class does not have access
to it's own private constructors/destructors? It has access to
everyting else, why not that? I brought this up on
comp.lang.c++.moderated a little while ago and those who responded (if I
remember correctly) agreed with me, however the thread didn't recieve
very much attention.
> >---bug2.cc---
> >/* BUG: Constant enum's arent always handled correctly */
>
> The same would happen with straightforward 'int' instead of 'enum
> index'
Yes, you are right. I guess I don't know all that much about
compile-time const stuff. Thanks.
Doug Eleveld
- Raw text -