Is it ok to use the destructor inside function of a class to reset values?

Viewed 358

In my lectures I don't see anyone using the destructor for reseting values to there starting parameters instead doing every variable manually in the function. Will using a destructor in a class function for reseting/deleting cause any issues

Small example of what I mean:

    class Test1{
        private:
            int *test;
            bool valid;
        public:
        Test1(int value,bool valid=false){
            test=new int(value); this->valid=valid;
        }
        ~Test1(){
            delete test; test=nullptr; valid=false;
        }

    void ResetStats(int NewValue){
        this->~Test1();
        test1=new int(NewValue);
        valid=false;
    }

    }
2 Answers
Related