码迷,mamicode.com
首页 > 其他好文 > 详细

Rule of three & Rule of five

时间:2014-08-09 23:03:59      阅读:331      评论:0      收藏:0      [点我收藏+]

标签:des   http   io   strong   for   ar   cti   amp   

Reference:http://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming)

The rule of three (also known as the Law of The Big Three or The Big Three) is a rule of thumb in C++ that claims that if a class defines one of the following it should probably explicitly define all three:[1]

These three functions are special member functions. If one of these functions is used without first being declared by the programmer it will be implicitly implemented by the compiler with the default semantics of performing the said operation on all the members of the class. The default semantics are:

  • Destructor - Call the destructors of all the object‘s class-type members
  • Copy constructor - Construct all the object‘s members from the corresponding members of the copy constructor‘s argument, calling the copy constructors of the object‘s class-type members, and doing a plain assignment of all non-class type (e.g., int or pointer) data members
  • Copy assignment operator - Assign all the object‘s members from the corresponding members of the assignment operator‘s argument, calling the copy assignment operators of the object‘s class-type members, and doing a plain assignment of all non-class type (e.g., int or pointer) data members.

the rule of five we have the following special members:

 

Rule of three & Rule of five,布布扣,bubuko.com

Rule of three & Rule of five

标签:des   http   io   strong   for   ar   cti   amp   

原文地址:http://www.cnblogs.com/MyloverisU/p/3901643.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!