我正在尝试联系人列表有点应用,并希望将这些数据保存在动态数组中。 CIwArray
是我的选择,因为我之前使用过它。然而现在它的工作很奇怪,可能是因为Marmalade 7.4.2因为我刚刚更新了。
我在头文件中的声明是这样的 -
CIwArray<ContactData*> m_ContactList;
我推回这样的数据 -
ContactData* contact = new ContactData;
m_ContactList.push_back(contact);
在回推调用中,我经常遇到访问冲突错误,当我打破它时,我得到m_ContactList的结构为NULL,而联系对象工作正常。我不明白我错在哪里。我试图通过将泛型类型更改为int来推回整数,但我得到相同的错误。被点击的IwAssert在IwArray.h的第650行 -
int push_back(X const & x)
{
// This IwAssertion fires if you've passed a reference to a controlled
// object (which might become invalid if the memory buffer moves before
// we dereference it!)
// I don't think this is an unreasonable requirement, since the
// alternative would be to create a copy of the object on the stack.
// If you need to do this behaviour, code like:
// {
// CIwArray< ThingZ > array_z;
// // fill up array_z with something or other here before trying:
// array_z.push_back( ThingZ( array_z[0] ) );
// }
// should work. (Although it's not terribly elegant.)
IwAssert(CORE, !(&x>=p && &x<p+max_p)); //THAT"S WHAT HITTING EVERY TIME
reserve(num_p+1);
IwAssert(CORE, num_p < max_p);
new (p+num_p) X(x);
return num_p++;
}
我不明白评论的意思。任何人都可以解释一下吗? 感谢