Looking at some old code of mine, I see that out of clumsiness I defined a destructor like so :
~ResourceManager(void);
This not only compiles, but works as expected. I changed it of course to
~ResourceManager();
but was I too quick to refactor? Is the first version correct and good C++ style?
EDIT
Since the question was closed and won't get any chance for proper disambiguation, I should put the related quote from the standard that answers this question, when destructors are put in perspective
12.4 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. In such a declaration, the ˜ followed by the destructor’s class name can be enclosed in optional parentheses; such parentheses are ignored. A typedef-name shall not be used as the class-name following the ∼ in the declarator for a destructor declaration.
So the standard mandates an empty parameter list. Maybe backwards compatibility with C practices for free functions (where f(void)
is the way to declare an empty parameter list) took destructors along with them in implementations, but it certainly doesn't seem to be valid C++.