从同一个类的不同方法调用析构函数

时间:2013-06-03 07:08:32

标签: c++ destructor

我遇到了问题

class Polygon 
{
    private:
        Vertex* vertices;
        int numVerts;
        static int RefCount;

    public:
        //Constructors
        Polygon(Vertex vert[], int numVerts){
            vertices = vert;
            this->numVerts = numVerts;
        }
        Polygon() {
            vertices = 0;
            numVerts = 0;
        }
        ~Polygon() {

        }
        ReleasePolygon()
        {
            if (RefCount == 0)
                delete this; // <-------- is this line ok?
            else
                RefCount--;
        }
}

这是否是此时调用析构函数的正确方法?

0 个答案:

没有答案