共用方式為


編譯器錯誤 C2533

'identifier':建構函式不允許傳回型別

備註

建構函式不能有傳回類型 (甚至是 void 傳回類型也不可以)。

此錯誤的常見來源是類別定義結尾與第一個建構函式實作之間遺漏分號。 編譯器會將類別視為建構函式的傳回型別定義,並產生 C2533。

Example

下列範例會產生 C2533,並示範如何修正它:

// C2533.cpp
// compile with: /c
class X {
public:
   X();
};

int X::X() {}   // C2533 - constructor return type not allowed
X::X() {}   // OK - fix by using no return type