编译器错误 C2533
“identifier”: 构造函数不能有返回类型
构造函数不能具有返回类型(甚至不能是 void
返回类型)。
此错误的常见来源是类定义结尾与第一个构造函数实现之间缺少分号。 编译器会将类视为构造函数返回类型的定义,会生成 C2533。
下面的示例生成 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