Click here to Skip to main content
15,895,606 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Network Pin
Mila0258-Jun-06 22:58
Mila0258-Jun-06 22:58 
QuestionHow to read image frames from .avi file [modified] Pin
dinyxu8-Jun-06 17:48
dinyxu8-Jun-06 17:48 
AnswerRe: How to read image frames from .avi file [modified] Pin
Hamid_RT8-Jun-06 18:53
Hamid_RT8-Jun-06 18:53 
QuestionFailed in Win2000 But Successful on WinXP When Using CreateCompatibleBitmap(...) ??? Pin
resocman8-Jun-06 16:22
resocman8-Jun-06 16:22 
AnswerRe: Failed in Win2000 But Successful on WinXP When Using CreateCompatibleBitmap(...) ??? Pin
bob169728-Jun-06 17:34
bob169728-Jun-06 17:34 
AnswerRe: Failed in Win2000 But Successful on WinXP When Using CreateCompatibleBitmap(...) ??? Pin
Michael Dunn8-Jun-06 18:03
sitebuilderMichael Dunn8-Jun-06 18:03 
AnswerRe: Failed in Win2000 But Successful on WinXP When Using CreateCompatibleBitmap(...) ??? Pin
Hamid_RT8-Jun-06 19:25
Hamid_RT8-Jun-06 19:25 
QuestionTemplates Help? Pin
G_S8-Jun-06 14:44
G_S8-Jun-06 14:44 
The following code is a very simple linked list it seems to work fine it compiles it runs and
the output is the desierd output but the problem i'm having is in this line of code

<br />
 if(m_cNext)<br />
{<br />
delete( m_cNext );<br />
m_cNext = NULL;<br />
}<br />

of the Reset member of the template.
It Gives me an error on debug but not on release.
Access violation writing location 0x00030fd4.

I'm simply not seeing the problem any suggestions help would be helpful.



<code>

#include< windows.h >
#include< iostream.h >
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   
   Linked List

   
   
   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
template < typename xType > 
class CLinked
{
public:
	CLinked();
	~CLinked();

	void SetCallDelete(BOOL b) {
		                         m_bCallDelete = b; 
								 if( m_Next )
									 m_Next->SetCallDelete(b);
	                           }


	xType* GetObject()    { return(m_ObjData); }
	CLinked* GetNext()    { return(m_cNext);   }
	CLinked* GetPrev()    { return(m_cPrev);   }
	CLinked* AddObject(xType* pvPtr,CLinked* prev=NULL);

	void ReplaseObject(xType* obj) { m_ObjData = obj; }
	void Reset();

private:
	xType* m_ObjData;
	CLinked* m_cPrev;
	CLinked* m_cNext;
	BOOL m_bCallDelete;
};

template < typename xType > 
CLinked< xType >::CLinked()
{
	m_bCallDelete = TRUE;
	m_cPrev = NULL;
	m_cNext = NULL;
	m_ObjData = NULL;
}

template < typename xType >  
CLinked< xType >::~CLinked()
{
	if( m_bCallDelete )
	{
		if( m_ObjData )
            delete( m_ObjData );
		m_ObjData = NULL;
	}
	if(m_cNext)
	{
		delete( m_cNext );
		m_cNext = NULL;
	}
}


template < typename xType >  
void CLinked< xType >::Reset()
{
	if( m_bCallDelete )
	{
		if( m_ObjData )
            delete( m_ObjData );
		m_ObjData = NULL;
	}
	if(m_cNext)
	{
		delete( m_cNext );
		m_cNext = NULL;
	}
	m_cPrev = NULL;
	m_cNext = NULL;
	m_ObjData = NULL;


}


template < typename xType >  
CLinked< xType >* CLinked< xType >::AddObject(xType* pvPtr, CLinked* cpPrev)
{
	// if NULL fail
	if( pvPtr == NULL )
		return( NULL );

	// if current has no obj store it
	if( m_ObjData == NULL )
	{
		m_ObjData = pvPtr;
		m_cPrev = cpPrev;
		return( this );
	}

	if( m_cNext )
	{
		return( m_cNext->AddObject(pvPtr,this) );        	
	}

	m_cNext = new CLinked();
	if( m_cNext == NULL )
		return(NULL);

	return( m_cNext->AddObject(pvPtr,this) );
}



typedef CLinked< int > _intList;
#define MAXSIZE 10000

int main(int argc, _TCHAR* argv[])
{
	_intList SomeList;
	_intList* tmp = &SomeList;
	int* piNum = NULL;
	int i;

	for(i=0 ; i < MAXSIZE; i ++ )
	{
		piNum = new int;
		if( !piNum )
		{
			cout<<"Error int allocation"<<endl;
			return(FALSE);
		}
		*piNum = i;
		tmp = tmp->AddObject(piNum);

		if(!tmp)
		{
			cout<<"List Error"<<endl;
			return(FALSE);
		}

	}
	
	for(tmp=&SomeList ; tmp ; tmp = tmp->GetNext())
	{
		cout<< *tmp->GetObject()<<" , ";
	}

	
	try
	{ 
		SomeList.Reset();
	}
	catch(...)
	{
		cout<<"ERRRORRRRR"<<endl;
	}


	return 0;
}

</code>


G_S
AnswerRe: Templates Help? [modified] Pin
Justin Tay8-Jun-06 17:31
Justin Tay8-Jun-06 17:31 
QuestionLarge Character Text Pin
pblais8-Jun-06 13:43
pblais8-Jun-06 13:43 
AnswerRe: Large Character Text Pin
G_S8-Jun-06 15:31
G_S8-Jun-06 15:31 
GeneralRe: Large Character Text Pin
Ryan Binns8-Jun-06 19:54
Ryan Binns8-Jun-06 19:54 
QuestionCan DirectShow play Mp3 stream? Pin
Cyrus Dang8-Jun-06 11:22
Cyrus Dang8-Jun-06 11:22 
AnswerRe: Can DirectShow play Mp3 stream? Pin
hmklakmal8-Jun-06 12:11
hmklakmal8-Jun-06 12:11 
AnswerRe: Can DirectShow play Mp3 stream? Pin
Justin Tay8-Jun-06 16:48
Justin Tay8-Jun-06 16:48 
GeneralRe: Can DirectShow play Mp3 stream? [modified] Pin
Cyrus Dang9-Jun-06 4:10
Cyrus Dang9-Jun-06 4:10 
GeneralRe: Can DirectShow play Mp3 stream? Pin
Justin Tay10-Jun-06 4:33
Justin Tay10-Jun-06 4:33 
AnswerRe: Can DirectShow play Mp3 stream? Pin
Hamid_RT8-Jun-06 19:05
Hamid_RT8-Jun-06 19:05 
GeneralRe: Can DirectShow play Mp3 stream? Pin
Cyrus Dang9-Jun-06 4:13
Cyrus Dang9-Jun-06 4:13 
QuestionWant to plot some points on something from within a dll Pin
ns8-Jun-06 10:56
ns8-Jun-06 10:56 
QuestionHow to know when Dialog is open Pin
sschilachi8-Jun-06 10:53
sschilachi8-Jun-06 10:53 
AnswerRe: How to know when Dialog is open Pin
Michael Dunn8-Jun-06 10:59
sitebuilderMichael Dunn8-Jun-06 10:59 
QuestionRe: How to know when Dialog is open [modified] Pin
sschilachi8-Jun-06 11:18
sschilachi8-Jun-06 11:18 
AnswerRe: How to know when Dialog is open [modified] Pin
Roger Stoltz8-Jun-06 13:02
Roger Stoltz8-Jun-06 13:02 
QuestionRe: How to know when Dialog is open [modified] Pin
sschilachi8-Jun-06 23:14
sschilachi8-Jun-06 23:14 

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.