我有兩個構造函數,有一個字節*成員如下結構:如何在另一個結構中使用帶有結構的結構對象?
struct structA
{
byte* pData; int nLength;
structA()
{
pData = NULL; nLength = 0;
}
structA(int nLen)
{
pData = new byte[nLen]; nLength = nLen;
}
~structA()
{
delete[] pData;
}
}
另一種結構即structB具有structA的列表:
struct structB
{
CList <structA, structA&> AList;
}
現在我創建structA的物體參數10作爲輸入,並把它添加到structB的目的:
//的範圍開始
structA osA(10);
structB osB;
osB.AList.AddTail(osA);
//範圍結束
問題是,當程序退出範圍時,structA的結構被調用2次並且程序崩潰。
問題及其原因是什麼? 任何幫助都可以得到
可能的重複http://stackoverflow.com/questions/4172722/what-is-the-rule-of-reeree –