Destructor parameters

Section §12.4 of C++0x draft n3290 has this to say about destructors: Destructors A special declarator syntax using an optional function-specifier (7.1.2) followed by ˜ followed by the destructor’s class name followed by an empty parameter list is used to declare the destructor in a class definition. (emphasis added) So no, destructors do not take … Read more

May a destructor be final?

May a C++ destructor be declared as final? Yes. And if so, does that prevent declaration of a derived class: Yes, because the derived class would have to declare a destructor (either explicitly by you or implicitly by the compiler), and that destructor would be overriding a function declared final, which is ill-formed. The rule … Read more

Time complexity of delete[] operator [duplicate]

::operator delete[] is documented on cplusplus.com (which is sometimes frowned upon) as: operator delete[] can be called explicitly as a regular function, but in C++, delete[] is an operator with a very specific behavior: An expression with the delete[] operator, first calls the appropriate destructors for each element in the array (if these are of … Read more

Manually destroy C# objects

You don’t manually destroy .Net objects. That’s what being a managed environment is all about. In fact, if the object is actually reachable, meaning you have a reference you can use to tell the GC which object you want to destroy, collecting that object will be impossible. The GC will never collect any object that’s … Read more

Is this C++ destructor redundant?

Yes, the destructor is completely redundant. As you’ve said yourself the code has other warnings signs. Using typedef struct for instance makes no sense whatsoever in C++, it’s as redundant as the empty destructor: The code was written by somebody with a marginal grasp of C++, there are bound to be more gotchas (for one … Read more

What’s the difference between “= default” destructor and empty destructor?

Your first example should not compile. This represents a bug in the compiler that it does compile. This bug is fixed in gcc 4.9 and later. The destructor defined with = default is trivial in this case. This can be detected with std::is_trivially_destructible<A>::value. Update C++11 (and C++14) state that if one has a user-declared destructor … Read more

How to write a simple class in C++?

Well documented example taken and explained better from Constructors and Destructors in C++: #include <iostream> // for cout and cin class Cat // begin declaration of the class { public: // begin public section Cat(int initialAge); // constructor Cat(const Cat& copy_from); //copy constructor Cat& operator=(const Cat& copy_from); //copy assignment ~Cat(); // destructor int GetAge() const; … Read more

Right way to clean up a temporary folder in Python class

Caveat: you can never guarantee that the temp folder will be deleted, because the user could always hard kill your process and then it can’t run anything else. That said, do temp_dir = tempfile.mkdtemp() try: <some code> finally: shutil.rmtree(temp_dir) Since this is a very common operation, Python has a special way to encapsulate “do something, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)