What legal code can cause C4523 "multiple destructors specified" Visual C ++ Warning?

According to MSDN, Visual C ++ may issue C4523 warning 'class': several destructors are specified. How is this possible?

I tried the following:

class Class { ~Class(); ~Class(int); }; 

which the destructor gives must have a parameter list error "void" and warning C4523 and the following

 class Class { ~Class(); ~Class(); }; 

which gives the member function an already defined or declared error and the following

 class Class { int ~Class(); ~Class(); }; 

which the destructor gives cannot have a return type error.

So, how can I get warning C4523 and no errors?

+6
source share
3 answers

The following is warning C4523, but it is also preceded by an error

 struct Foo { ~Foo() {} ~Foo() const {} }; error C2583: 'Foo::~Foo' : 'const' 'this' pointer is illegal for constructors/destructors warning C4523: 'Foo' : multiple destructors specified 
+3
source

Here is another example of several destructors - an error, not a warning:

 class C { ~C(); ~C() volatile; }; 
+2
source

Wild assumption: could it be through multiple class inheritance? Say if class C inherits from both classes A and B, and A and B define a destructor, but C does not.

0
source

Source: https://habr.com/ru/post/900212/


All Articles