本文介绍了C ++新&amp;删除和功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这有点不清楚我...所以,如果我有一个函数:This is a bit unclear to me... So, if I have a function:char *test(int ran){ char *ret = new char[ran]; // process... return ret;},然后多次调用:for(int i = 0; i < 100000000; i++){ char *str = test(rand()%10000000+10000000); // process... // delete[] str; // do i have to delete it here?} $ b推荐答案您不有。但是如果你不删除内存你保留与'新',你将开始运行内存最终(内存泄漏)。You don't have to. But if you don't delete memory you reserved with 'new' you will start running out of memory eventually (memory leak). 这篇关于C ++新&amp;删除和功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 09:08
查看更多