There's a point in my program where the state of a certain object needs to be reset "to factory defaults". The task boils down to doing everything that is written in the destructor and constructor. I could delete and recreate the object - but can I instead just call the destructor and the constructor as normal objects? (in particular, I don't want to redistribute the updated pointer to the new instance as it lingers in copies in other places of the program).
  MyClass {
  public:
        MyClass();
        ~MyClass();
  ...      
  }
  void reinit(MyClass* instance)
  {
        instance->~MyClass();
        instance->MyClass();
  }
Can I do this? If so, are there any risks, caveats, things I need to remember?
 
     
     
     
     
     
     
    