全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Rule of zero, rule of five?

又称: rule of zero · rule of five

Definition 2.11 University Computer Science — Year 2 · 第 2 章 — Copying, Moving and Smart Pointers

The rule of zero says that a class whose members all manage their own resources (strings, containers, smart pointers) should declare none of the five special members: the member-wise versions the compiler writes are correct. The rule of five says that a class that manages a resource itself, and so declares one of the five, should declare all five, each written or explicitly = default or = delete.

在原文中阅读 →