編譯器錯誤 C3073
'type' : ref 類別沒有使用者定義的複製建構函式
在 /clr (Common Language Runtime 編譯) 編譯中,編譯程式不會產生參考類型的複製建構函式。 在任何 /clr 編譯中,如果您預期要複製類型的實例,則必須為參考類型定義自己的複製建構函式。
如需詳細資訊,請參閱 參考類型的堆棧語意C++。
範例
下列範例會產生 C3073。
// C3073.cpp
// compile with: /clr
ref class R {
public:
R(int) {}
};
ref class S {
public:
S(int) {}
S(const S %rhs) {} // copy constructor
};
void f(R) {}
void f2(S) {}
void f3(R%){}
int main() {
R r(1);
f(r); // C3073
f3(r); // OK
S s(1);
f2(s); // OK
}