C++11中的delete关键字
C++11 中,可在想要 “禁止使用” 的特殊成员函数声明后加 “= delete”(当然也可以声明为私有函数或者保护函数),而需要保留的加 "= default" 或者不采取操作
class LeafOfTree{ public: LeafOfTree() = default; ~LeafOfTree() = default; LeafOfTree(const LeafOfTree&) = delete; // mark copy ctor or copy assignment operator as deleted functions LeafOfTree & operator=(const LeafOfTree&) = delete; };
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: C++11中delete的使用
- 下一篇: c++ 求数组最大最小值函数