   You learn something every day.
  I am dealing with static variables in static member functions right now.  However, I just found out that when those variables are deleted, it counts as if they are being deleted from inside of the class.  Now, since that sentence makes no sense, I'll give an example.  I'm making a Meyer's singleton (the kind that returns a static variable from inside your instance function), and the destructor is private.  It compiles fine.   
  That's right, static member functions have the same access permissions as regular member functions. Ie, they can access private members of the class in which they are defined. There's nothing special going on here.   ;Quote:Original post by DocThat's right, static member functions have the same access permissions as regular member functions. Ie, they can access private members of the class in which they are defined. There's nothing special going on here.No, it was a static variable which was declared inside of the static function.static Engine& Instance(){   static Engine Instance;   return Instance;};  Eh firstly your Instance is of a static type so you dont need to manually delete it.If it were static Engine* Instance;   return Instance;You can delete it by using a public static method.class Engine{public:static void deleteEngine(){delete Instance;Instance = 0;}static Engine* getEngine(){   if(!Instance)   {Instance = new Engine();   }   return Instance;};private:Engine();~Engine();static Engine* Instance;};  I don't delete it, but if you declare the destructor of a class private, you can't make an object of that class on the stack, or as a member of a non-friend class because the destructor of that class will be called outside of the it's own scope.  What I found was that a static variable of a function of a class is deleted inside of class scope, even though it isn't a member of the class, or on the stack in a function of the class.  That last sentence makes absolutely no sense, so re-read it 40-50 times; it's true.EDIT: Well, almost true.  I was right about not being able to make one on the stack, but WTF is up with this warning (my main() has only return 0, here are the two classes):class A{~A(){}};class B{A a;};I get this warning:c:\Documents and Settings\Dan\My Documents\Visual Studio Projects\RTS Classes\Main.cpp(39) : warning C4624: 'B' : destructor could not be generated because a base class destructor is inaccessibleHuh?  I'm not inheriting...!   ;Quote:Original post by thedevdanQuote:Original post by DocThat's right, static member functions have the same access permissions as regular member functions. Ie, they can access private members of the class in which they are defined. There's nothing special going on here.No, it was a static variable which was declared inside of the static function.So the function isn't a member? In that case, there's probably something in the standard that makes destructors always public. That would make sense.   ;Quote:Original post by DocQuote:Original post by thedevdanQuote:Original post by DocThat's right, static member functions have the same access permissions as regular member functions. Ie, they can access private members of the class in which they are defined. There's nothing special going on here.No, it was a static variable which was declared inside of the static function.So the function isn't a member? In that case, there's probably something in the standard that makes destructors always public. That would make sense.No, it is a static variable declared inside of a static member function of a singleton class with a private constructor.   ;Quote:Original post by thedevdanI don't delete it, but if you declare the destructor of a class private, you can't make an object of that class on the stack, or as a member of a non-friend class because the destructor of that class will be called outside of the it's own scope.  What I found was that a static variable of a function of a class is deleted inside of class scope, even though it isn't a member of the class, or on the stack in a function of the class.Wait wait wait. Do you have this:class Thingy {private:~Thingy() {}public:static Thingy& getThingy() {static Thingy t;return t;}};If this is pretty much what you've got, my original point stands. While I might be misusing the term "member", the getThingy function is still within the scope of the Thingy class and thus has its permissions.EDIT: Forgot a "static".   ;  Doc: I knew that would work, but the variable is static, too.  Since it isn't really in scope of the class, I didn't expect that.  However, my other example completely baffles me (with A and B).   ;Quote:I get this warning:c:\Documents and Settings\Dan\My Documents\Visual Studio Projects\RTS Classes\Main.cpp(39) : warning C4624: 'B' : destructor could not be generated because a base class destructor is inaccessibleHuh? I'm not inheriting...!The warning is a little misleading, but it's correct to warn; A::~A() is private, so B::~B() can't call it.  Since this is what B::~B() would do by default, the compiler can't generate B::~B() for you, as it doesn't know what it should do.  You should probably make A::~A() public.