2014-11-13 3 views
0

연락처 목록을 사용하려고하는데이 데이터를 동적 배열에 보관하려고합니다. CIwArray은 이전에 사용했기 때문에 제 선택 사항이었습니다. 그러나 지금 막 이상하게 작동하고 있습니다. 마멀레이드 7.4.2 때문일 겁니다.CIwArray push_back 오류가 발생했습니다

헤더 파일 내 선언은 다음과 같다 -이 같은 데이터를 다시 밀어

CIwArray<ContactData*> m_ContactList; 

그리고 - 나는 끊임없이 무엇입니까 푸시 다시 호출에

ContactData* contact = new ContactData; 
m_ContactList.push_back(contact); 

액세스 위반 오류 때 연락처 개체가 정상적으로 작동하는 동안 m_ContactList에 대해 NULL로 구조체가 생성됩니다. 내가 잘못한 곳을 이해하지 못한다. 제네릭 형식을 int로 변경하여 정수를 다시 밀어 넣으려고했지만 동일한 오류가 발생합니다.

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++; 
    } 

내가 댓글이 말하는 내용을 이해하지 못할 - 박히는 년대 IwAssert 라인 (650)에 IwArray.h입니다. 아무도 설명 할 수 있을까요?
감사합니다.

답변

0

이 질문에 대한 답변은 another SO Question에서 왔습니다. 문제는 클래스의 인스턴스를 만들지 않고 NULL 객체에서 코드를 호출하는 것이 었습니다.
More Details