函數后面加delete

The common idiom of "prohibiting copying" can now be expressed directly:

class X {
    // ...
    X& operator=(const X&) = delete;  // Disallow copying
    X(const X&) = delete;
};

[...]

The "delete" mechanism can be used for any function. For example, we can eliminate an undesired conversion like this:

struct Z {
    // ...

    Z(long long);     // can initialize with an long long         
    Z(long) = delete; // but not anything less
};

參考資料:
http://stackoverflow.com/questions/5513881/meaning-of-delete-after-function-declaration

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,916評論 0 23
  • 食指 鄧伊彤 你的姿態, 雖然不如其它手指窈窕,但你的工作卻很復雜。 你的曲線, 雖是直直...
    悅讀生活閱讀 511評論 0 0
  • 最近刷朋友圈,看著同學們發的狀態,似乎多少也有迷茫的唏噓感,為著自己的未來而擔憂,又或者開始覺得自己一事無成,陷落...
    凌南絮閱讀 508評論 4 4