Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 C++/CX ref 类,其中包含一个非托管 C++ 类的指针。ref 类不需要任何复制构造函数,因为它们由引用购买管理,在这种情况下我是否需要编写 ref 类的复制构造函数以避免该非托管指针的任何浅拷贝?
C++ 编译器强制执行 a 的引用类型行为ref class。并且不会像常规 C++ 类那样自动生成复制构造函数和赋值运算符。如果您尝试复制构造,您将被打耳光:
ref class
类 "Foo::Bar" 没有合适的复制构造函数
所以不,故意= delete没有必要。使用您的 ref 类的客户端语言将具有相同的限制。
= delete