I have a C++/CX ref class that contains a pointer of an un-managed C++ class. The ref class don't need any copy constructor because they are managed by reference buy should I need to write the copy constructor of the ref class in this case to avoid any shallow copy of that un-managed pointer?
Asked
Active
Viewed 274 times
1 Answers
1
The C++ compiler enforces the reference type behavior of a ref class
. And does so by not auto-generating a copy constructor and assignment operator like it does for a regular C++ class. If you try to copy-construct you'll be slapped by:
class "Foo::Bar" has no suitable copy constructor
So no, intentionally = delete
is not necessary. Client languages that use your ref class will have the same restriction.

Hans Passant
- 922,412
- 146
- 1,693
- 2,536