calling the contructor again
hi Guys,
i got a question...
lets say i have a class "A" that can only be constructed with an int parameter
like this:
how can i reinitialized objA?
first attempt:
Code:
A objA(1);
objA(2);
but i get a compile error that the term doesn't evaluate to to 1 argument. am i missing parameters? ( there is nothing else named objA )
second attempt:
Code:
A objA(1);
objA.A(2);
i get the error : 'function-style cast' : illegal as right side of '.' operator
if i do this:
Code:
A objA(1);
objA = A(2);
against my will the deconstructor of the temporary object get called and the copied data members become invalid.
i've tried this:
Code:
A objA(1);
objA = A(2);
A objNewA(2);
objA = objNewA;
but when objNewA goes out of scope it will get destructed.
basicly i just want to call the constructor of an object again. do i have to use A by reference or something?
can someone please explain?