recall constructor?

Dec 19, 2009 at 5:34am
I would like to know whether is it possible to recall the constructor of an object. So say I created an object and change its data whatsoever, and then I want to reset all its value, can I somehow recall the constructor? And no, I do not want something like:
object = ClassName( argument );
because this object contains pointers that dynamically allocates memory.
Dec 19, 2009 at 5:45am
No, as far as I know. You could however do sometihing like
1
2
3
4
5
6
7
8
class MyClass{
    void Reset(){
         //construction
    }
    MyClass(){
         Reset();
    }
}

And call "Reset" whenever you want.
Topic archived. No new replies allowed.