C++11中的delete关键字

xiaoxiao2021-02-28  69

 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; };

转载请注明原文地址: https://www.6miu.com/read-34974.html

最新回复(0)