I have a class myclass
.
In the main function, I create objects of type myclass
in every iteration and want to delete them after each iteration. I have not created the objects dynamically. Can I delete the them explicitly because I don't need them after the iteration gets over.
class myclass{
int value;
void do_function();
};
int main()
{
for(int i=0;i<count;i++)
{
myclass obj;
obj.do_function();
}
}
The object obj
is not needed after one iteration, but the memory is still there. How can I free that memory?