would this be the correct way to use c++/sfml in order to avoid memory leaks?:sprite.~Sprite();
texture.~Texture();
You don't need to manually call the destructors like that.In fact, you should never manually call the destructor, since it's not defined and thus can lead to undefined behavior, which in turn could magically work, it could lead to strange issues, well strictly speaking anything could happen.
Oh, I was unaware that the destructors are undefined( I never looked for them because I never needed them)The destructors itself are not undefined, but you run into undefined behavior when you manually call the destructor.
In fact, you should never manually call the destructor, since it's not defined and thus can lead to undefined behavior, which in turn could magically work, it could lead to strange issues, well strictly speaking anything could happen.Never say never ;). I am pretty sure if the C++ standardization committee saw explicit destructor calls as something that should never be done, they would just make it illegal in the language specification. Since it isn't, you have to ask yourself, which C++ archwizard could think of such a good reason to make it legal that they allowed it.
Never say never ;). I am pretty sure if the C++ standardization committee saw explicit destructor calls as something that should never be done, they would just make it illegal in the language specification. Since it isn't, you have to ask yourself, which C++ archwizard could think of such a good reason to make it legal that they allowed it.
For beginners though, just pretend that what eXpl0it3r said is 100% true and think about it in another 4 years ;).I'm well aware. :)