Compiler Error C2897
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.
Examples
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
};
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for