I just want to know if this is a bad practice to do.
for(int i=0;i<1000;i++)
happyFunction(new Car());
The new car()
object should live after calling it from happyFunction
and later it should be destroyed .
Now is that ok to do. I mean shouldn't I delete the memory allocated for that instance?
Example to make it more clear.
int i = 0;
for (i=0;i<1000;i++){
new car();
}
Is this a good practice to do? Should I delete the memory allocation? I hope my question is clear. thank you.