Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C3073

Error Message

'type' : ref class does not have a user-defined copy constructor

In a /clr (Common Language Runtime Compilation) compilation, the compiler will not generate a copy constructor for a reference type. In any /clr compilation, you must define your own copy constructor for a reference type if you expect an instance of the type to be copied.

For more information, see C++ Stack Semantics for Reference Types.

Example

The following sample generates 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
}

Community Additions

ADD
Show:
© 2015 Microsoft