Click here to Skip to main content
15,888,315 members
Home / Discussions / Mobile
   

Mobile

 
GeneralRe: CArray makes me cry !!!!!!! Pin
João Paulo Figueira5-Jul-04 11:32
professionalJoão Paulo Figueira5-Jul-04 11:32 
GeneralRe: CArray makes me cry !!!!!!! Pin
Hadi Rezaee5-Jul-04 11:36
Hadi Rezaee5-Jul-04 11:36 
GeneralRe: CArray makes me cry !!!!!!! Pin
João Paulo Figueira5-Jul-04 11:39
professionalJoão Paulo Figueira5-Jul-04 11:39 
GeneralRe: CArray makes me cry !!!!!!! Pin
João Paulo Figueira5-Jul-04 11:41
professionalJoão Paulo Figueira5-Jul-04 11:41 
GeneralRe: CArray makes me cry !!!!!!! Pin
Hadi Rezaee5-Jul-04 11:51
Hadi Rezaee5-Jul-04 11:51 
GeneralRe: CArray makes me cry !!!!!!! Pin
João Paulo Figueira5-Jul-04 12:04
professionalJoão Paulo Figueira5-Jul-04 12:04 
GeneralRe: CArray makes me cry !!!!!!! Pin
Hadi Rezaee5-Jul-04 12:08
Hadi Rezaee5-Jul-04 12:08 
GeneralRe: CArray makes me cry !!!!!!! Pin
João Paulo Figueira5-Jul-04 11:51
professionalJoão Paulo Figueira5-Jul-04 11:51 
Got it! Most of the times, we have to read MFC's source code to know whais is happening. Look:
AFX_INLINE int CArray<TYPE, ARG_TYPE>::Add(ARG_TYPE newElement)
	{ int nIndex = m_nSize;
		SetAtGrow(nIndex, newElement);
		return nIndex; }
.
.
.
template<class TYPE, class ARG_TYPE>
void CArray<TYPE, ARG_TYPE>::SetAtGrow(int nIndex, ARG_TYPE newElement)
{
	ASSERT_VALID(this);
	ASSERT(nIndex >= 0);

	if (nIndex >= m_nSize)
		SetSize(nIndex+1, -1);
	m_pData[nIndex] = newElement;
}

The code is using a reference type (ARG_TYPE) to add the objects, that you are passing as unnamed temporaries (when are these being deleted?). Try something like this:
void CMyDialog::SomeFunc1()
{
SomeStruct a(0,0);

a = SomeStruct( 1, 2 );
m_MrOdd.Add( a );

a = SomeStruct( 10, 2 );
m_MrOdd.Add( a );

a = SomeStruct( 1, 212 );
m_MrOdd.Add( a );
}

I know it looks odd, but try it.

Regards,
João Paulo Figueira
Embedded MVP
GeneralRe: CArray makes me cry !!!!!!! Pin
Hadi Rezaee5-Jul-04 12:04
Hadi Rezaee5-Jul-04 12:04 
GeneralRe: CArray makes me cry !!!!!!! Pin
João Paulo Figueira5-Jul-04 12:12
professionalJoão Paulo Figueira5-Jul-04 12:12 
GeneralRe: CArray makes me cry !!!!!!! Pin
Hadi Rezaee5-Jul-04 12:16
Hadi Rezaee5-Jul-04 12:16 
GeneralRe: CArray makes me cry !!!!!!! Pin
Hadi Rezaee5-Jul-04 12:14
Hadi Rezaee5-Jul-04 12:14 
GeneralRe: CArray makes me cry !!!!!!! Pin
João Paulo Figueira5-Jul-04 12:21
professionalJoão Paulo Figueira5-Jul-04 12:21 
GeneralRe: CArray makes me cry !!!!!!! Pin
Hadi Rezaee5-Jul-04 12:33
Hadi Rezaee5-Jul-04 12:33 
GeneralRe: CArray makes me cry !!!!!!! Pin
João Paulo Figueira5-Jul-04 22:50
professionalJoão Paulo Figueira5-Jul-04 22:50 
GeneralRe: CArray makes me cry !!!!!!! Pin
Hadi Rezaee6-Jul-04 1:39
Hadi Rezaee6-Jul-04 1:39 
GeneralRe: CArray makes me cry !!!!!!! Pin
Hadi Rezaee5-Jul-04 21:00
Hadi Rezaee5-Jul-04 21:00 
Generalreturn value from a register write Pin
Mel Feik5-Jul-04 9:19
Mel Feik5-Jul-04 9:19 
GeneralFree IDE Pin
monn4-Jul-04 16:05
monn4-Jul-04 16:05 
GeneralAccessing pocket access CDB using .NET Pin
Gobananas2-Jul-04 23:21
Gobananas2-Jul-04 23:21 
GeneralRe: Accessing pocket access CDB using .NET Pin
João Paulo Figueira3-Jul-04 0:00
professionalJoão Paulo Figueira3-Jul-04 0:00 
GeneralAfterCollapse in Compact Framework Pin
ting66830-Jun-04 21:10
ting66830-Jun-04 21:10 
GeneralChanging the BackColor of a ListViewItem Pin
George Papadopoulos30-Jun-04 7:00
George Papadopoulos30-Jun-04 7:00 
QuestionWriting to Pocket PC File - Directory Structure? Pin
j1e1g129-Jun-04 5:19
j1e1g129-Jun-04 5:19 
AnswerRe: Writing to Pocket PC File - Directory Structure? Pin
Richard Jones8-Jul-04 4:09
Richard Jones8-Jul-04 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.