i have a variable which holds instance of class var a=Objj(); now after doing something i have to reinitiate the variable a with new object like this a=Objj(); then later a=Objj();
is it a good practice? what happens to the older object?
CodePudding user response:
In your case the older object will be replaced with a new instance. What I would suggest is creating a clear() method that will reset the data in the instance. Otherwise your original suggestion will work depending on what it is you want to do exactly.
