編譯器錯誤 C3673
'type' : 類別沒有 copy-constructor
需要使用者定義的建構函式,才能複製 CLR ref 類型的物件。 如需詳細資訊,請參閱 參考類型的堆棧語意C++。
範例
下列範例會產生 C3673。
// C3673.cpp
// compile with: /clr
public ref struct R {
public:
R() {}
// Uncomment the following line to resolve.
// R(R% p) {}
};
int main() {
R r;
R s = r; // C3673
}
下列範例會產生 C3673。
// C3673_b.cpp
// compile with: /clr /c
// C3673 expected
using namespace System;
[AttributeUsage(AttributeTargets::Class)]
ref class MyAttr : public Attribute {
public:
MyAttr() {}
// Uncomment the following line to resolve.
// MyAttr(int i) {}
property int Priority;
property int Version;
};
[MyAttr]
ref class ClassA {}; // OK, no arguments
[MyAttr(Priority = 1)]
ref class ClassB {}; // OK, named argument
[MyAttr(123)]
ref class ClassC {}; // Positional argument
[MyAttr(123, Version = 1)]
ref class ClassD {}; // Positional and named