473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 4242
weaknessforcats
9,208 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

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

Similar topics

0
by: Ishira | last post by:
Here is a snippet of my program. It is really intresting... PREMISE: Class CobjA has a private CARRAY memeber m_Arr of objects CobjB. Class CobjB is a class with an int data variable called...
2
by: Ishira | last post by:
Hello, Please help. I am seriously at my wits end. Just when I feel I have completely understood copy contructor, I am stumped yet again. I have a class which has a CARRAY of objects. I am...
66
by: Mike Stenzler | last post by:
I am new to Template programming and I would like to create an array of user-defined class objects using MFC CArray. Normally I would use linked list processing - create an object class and then an...
0
by: Frank King | last post by:
Hi, I am using CArray and quick sort funciton to sort an array of double type of data points. I found an article in MSDN HOWTO: Quick Sorting Using MFC CArray-Derived Classes ID: Q216858 ...
5
by: Silly | last post by:
I have a legacy dll that has an important function that takes a CArray<WORD,WORD>& as it's only parameter. The dll is used by a number of internal applications and so can't be changed. I am...
1
by: db01092001 | last post by:
Hello, I'm interested in the internal organization of CArray, especially the execution time for the members, the operator respective: Determines the use of in constant time (O(1))? What about...
0
by: Josh McFarlane | last post by:
I'm currently reading raw data files for two arrays of floating point numbers. There are about 10k floating points per array per file, and I want to combine each file's arrays into a master...
10
by: fei.liu | last post by:
Consider the following sample code char * ptr = "hello"; char carray = "hello"; int main(void){ } What does the standard have to say about the storage requirement about ptr and carray? Is...
2
by: Dymus | last post by:
Ok here is sample of code: CArray <MyClass,MyClassarr; MyClass * obj; obj = new MyClass(); obj->some_field=some_value; arr.Add((*obj)); delete obj; ----
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.