Code:
class arr[3] = ..... .
./*construction for each element*/
destroy(arr[0]);
To do this, you'd need to have an array of pointers allocated with new:
Code:
Class* arr[3] = { new Class, new Class, new Class };
Code:
void destroy(class* i)
{
delete i;
i = NULL;
}
Here setting i to NULL serves no purpose, since the pointer i is a local variable and goes out of scope anyway (the caller's pointer will keep the same value).
Code:
void destroy(class* &i)
Here the pointer is passed by reference, hence changes to i in destroy will affect the value of the pointer passed in (the caller's pointer will be NULL after this call).