我正在使用此代码来填充我的数据库:
import os
def populate():
python_cat = add_cat('Python')
add_page(cat=python_cat,
title="Official Python Tutorial",
url="http://docs.python.org/2/tutorial/")
add_page(cat=python_cat,
title="How to Think like a Computer Scientist",
url="http://www.greenteapress.com/thinkpython/")
add_page(cat=python_cat,
title="Learn Python in 10 minutes",
url="http://www.korokithakis.net/tutorials/python/")
django_cat = add_cat(name="Django")
add_page(cat=django_cat,
title="Official Django Tutorial",
url="http://djangoproject.com/en/1.5/intro/tutorial01/")
add_page(cat=django_cat,
title="Django Rocks",
url="http://www.djangorocks.com/")
add_page(cat=django_cat,
title="How to Tango with Django",
url="htttp://www.tangowithdjango.com/")
frame_cat = add_cat(name="Other Frameworks")
add_page(cat=frame_cat,
title="Bottle",
url="http://bottlepy.org/docs/dev/")
add_page(cat=frame_cat,
title="Flask",
url="http://flask.pocoo.org")
# Print out what we have added to the user.
for c in Category.objects.all():
for p in Page.objects.filter(category=c):
print "- {0} - …Run Code Online (Sandbox Code Playgroud) 假设我有一个结构数组,而这些结构又有动态分配的数组,delete [] deep会删除我上面说的所有内容吗?
例如,考虑我有这样的结构:
struct A
{
char* name;
float* data;
int** image;
};
Run Code Online (Sandbox Code Playgroud)
我创建的代码中的某个位置
A** array = new A[n];
Run Code Online (Sandbox Code Playgroud)
我为我的数组中的所有结构分配内存
for(int i=0; i<n; i++)
{
array[i] = new A;
}
Run Code Online (Sandbox Code Playgroud)
然后一些其他地方类似地填充结构的内容(使用malloc/new创建名称,数据和图像).
现在,如果我说delete[] array;,到目前为止分配的所有内存(对于char*,float*,int**,结构和数组)是否会被销毁?