How do I destroy an instance of a class?
Posted on 2011-03-07
Let's say I have created class called Class. Then, I create an instance of Class called Instance.
Then, in Instance I run a bunch of calculations using data pertaining to 1 student in my class, by running Instance.PerformCalculations. Now imagine that I have 500 students. So I created a For loop such that it iterates through the calculations 500 times.
For (x=0; x < numStudents; x++)
Instance.PerformCalculations(x); //x identifies each unique student
Rather than resetting all of the variables in Instance to 0 to calculate the data for a new incoming student, I just want to DESTROY the instance and make a new one. How do I destroy "Instance"?
Then, after answering my question, is this the best way to do things?