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