的确没什么好办法,我能想到的最好办法是添加一个如下的代码
#ifdef _DEBUG
template <class T>
struct LinkedList
{
T data;
LinkedList<T> * next;
};
template <class T>
LinkedList<T>* asLList(CArray<T>& arr)
{
if (arr.GetSize() == 0)
return NULL;
LinkedList<T> * head = new LinkedList<T>;
head->data = arr[0];
head->next = NULL;
LinkedList<T> * p = head;
for (int i = 1; i < arr.GetSize(); i++)
{
p->next = new LinkedList<T>;
p = p->next;
p->data = arr[i];
p->next = NULL;
}
return head;
}
template <class T>
void delLList(LinkedList<T>* l)
{
if (l == NULL)
return;
delLList(l->next);
delete l;
}
#endif
使用的时候加上2行
void CQ757506Dlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CPoint aa;
aa.x=10;
aa.y=20;
CPoint bb;
bb.x=40;
bb.y=80;
CArray<CPoint> myArray;
myArray.Add(aa);
myArray.Add(bb);
#ifdef _DEBUG
LinkedList<CPoint> * pl = asLList(myArray);
delLList(pl);
#endif