468,513 Members | 1,837 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

CArray Setsize

class deque2
{
int m_iIndex; // record number
int m_iOffset; // number of record to insert/delete

};

class deque1
{
public:
std::deque<deque2> m_undoBuff;
std::deque<deque2>::iterator m_undoPtr;

deque1()
{
m_undoPtr = m_undoBuff.begin();
}

~deque1()
{
m_undoPtr = m_undoBuff.begin();
}

};

void CkkkDlg::OnBnClickedOk()
{

CArray<deque1,deque1&> carray1;


carray1.SetSize(1);
carray1[0].m_undoPtr=carray1[0].m_undoBuff.begin(); -> (1)


carray1.SetSize(3);
carray1[0].m_undoPtr=carray1[0].m_undoBuff.begin();-> (2)

}

this code is running fine at (1) where as it is giving error at (2)
Thanks in advance, please tell me the error in the code
Dec 6 '07 #1
2 3884
weaknessforcats
9,207 Expert Mod 8TB
Is CArray running your deque1 constructors ??

I mean, were this a vector, the array is empty so subscript 0 is invalid until you put an object in the container.

BTW: Why CArray and not vector<> ???
Dec 6 '07 #2
Is CArray running your deque1 constructors ??

I mean, were this a vector, the array is empty so subscript 0 is invalid until you put an object in the container.

BTW: Why CArray and not vector<> ???
This code is building fine in VC++2003 where as it is giving runtime error
"Unhandled exception at 0x00413ff0 in kkk.exe: 0xC0000005: Access violation reading location 0xfeeefef2."



Call Stack
> kkk.exe!std::_Iterator_base::_Orphan_me() Line 174 + 0x3 bytes C++
kkk.exe!std::_Iterator_base::operator=(const std::_Iterator_base & _Right={...}) Line 142 C++
kkk.exe!std::_Ranit<deque2,int,deque2 const *,deque2 const &>::operator=(const std::_Ranit<deque2,int,deque2 const *,deque2 const &> & __that={...}) + 0x2f bytes C++
kkk.exe!std::_Deque_const_iterator<deque2,std::all ocator<deque2>,1>::operator=(const std::_Deque_const_iterator<deque2,std::allocator<d eque2>,1> & __that=deque[0] = {m_iIndex=1 m_iOffset=2 }) + 0x2f bytes C++
kkk.exe!std::_Deque_iterator<deque2,std::allocator <deque2>,1>::operator=(const std::_Deque_iterator<deque2,std::allocator<deque2> ,1> & __that=deque[0] = {m_iIndex=1 m_iOffset=2 }) + 0x2f bytes C++
kkk.exe!CkkkDlg::OnBnClickedOk() Line 197 + 0x49 bytes C++
mfc80d.dll!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x0012fe2c, unsigned int nID=1, int nCode=0, void (void)* pfn=0x004118c0, void * pExtra=0x00000000, unsigned int nSig=56, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 82 C++
mfc80d.dll!CCmdTarget::OnCmdMsg(unsigned int nID=1, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 381 + 0x27 bytes C++
mfc80d.dll!CDialog::OnCmdMsg(unsigned int nID=1, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Line 85 + 0x18 bytes C++
mfc80d.dll!CWnd::OnCommand(unsigned int wParam=1, long lParam=69116) Line 2300 C++
mfc80d.dll!CWnd::OnWndMsg(unsigned int message=273, unsigned int wParam=1, long lParam=69116, long * pResult=0x0012f7f4) Line 1755 + 0x1e bytes C++
mfc80d.dll!CWnd::WindowProc(unsigned int message=273, unsigned int wParam=1, long lParam=69116) Line 1741 + 0x20 bytes C++
mfc80d.dll!AfxCallWndProc(CWnd * pWnd=0x0012fe2c, HWND__ * hWnd=0x00010df8, unsigned int nMsg=273, unsigned int wParam=1, long lParam=69116) Line 240 + 0x1c bytes C++
mfc80d.dll!AfxWndProc(HWND__ * hWnd=0x00010df8, unsigned int nMsg=273, unsigned int wParam=1, long lParam=69116) Line 389 C++
Dec 7 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Ishira | last post: by
2 posts views Thread by Ishira | last post: by
66 posts views Thread by Mike Stenzler | last post: by
5 posts views Thread by Silly | last post: by
1 post views Thread by db01092001 | last post: by
reply views Thread by Josh McFarlane | last post: by
2 posts views Thread by Dymus | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.