This documentation is archived and is not being maintained.

Compiler Error C2897

Error Message

a destructor/finalizer cannot be a function template

Destructors or finalizers cannot be overloaded, so declaring a destructor as a template (which would define a set of destructors) is not allowed.

The following sample generates C2897:

Example

The following sample generates C2897.

// C2897.cpp
// compile with: /c
class X {
public:
   template<typename T> ~X() {}   // C2897
};

The following sample generates C2897.

// C2897_b.cpp
// compile with: /c /clr
ref struct R2 {
protected:
   template<typename T> !R2(){}   // C2897 error
};
Show: