When do I need to declare my own destructor?

前端 未结 6 854
时光取名叫无心
时光取名叫无心 2020-12-31 05:00
class Point    
{
public:
    float x,y;
    Point() {}
    Point(float,float);
    Point operator + (Point);
    Point operator * (double);
    void rotate_p(float)         


        
6条回答
  •  生来不讨喜
    2020-12-31 05:31

    You might also want to look at the "Rule Of Three" 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:

    destructor, copy constructor, copy assignment operator, Wikipedia Link: http://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming)

提交回复
热议问题