Topic: static variable in friend function + private destructor - problem?
Author: "Tom McKearney" <no@spam.com>
Date: 1998/02/11 Raw View
Excuse the confusing subject, but I couldn't think of another way to put it:
I am trying to do the following (a simple singleton from More Effective C++)
class foo
{
friend foo& theFoo();
private:
foo();
~foo(); // why is this an error?
};
foo& theFoo()
{
static foo _theFoo;
return _theFoo;
}
It seems to me that, since theFoo() is a friend function, it should be ok
for the destructor
to be private along with the constructor. The static variable is declared
inside the function.
Is this just my crap compiler or is there something I'm missing? (compiler
= MicroSloth VC++ 5.0 SP3)
Thanks in advance.
Tom McKearney
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]