Compiler Error C2521
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C2521.
function does not take any arguments
You attempted to use arguments with a destructor or finalizer.
For more information, see Destructors and finalizers.
The following sample generates C2521.
// C2521.cpp
// compile with: /clr
ref class R {
protected:
!R() {}
public:
void CleanUp() {
this->!R(4); // C2521
this->!R(); // OK
}
};
int main() {
R^ r = gcnew R();
r->CleanUp();
}
Show: