共用方式為


編譯器錯誤 C2897

解構函式/完成項不可為函式範本

解構函式或完成項無法多載,因此不允許將解構函式宣告為範本(這會定義一組解構函式)。

範例

下列範例會產生 C2897。

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

下列範例會產生 C2897。

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