Click here to Skip to main content
16,010,488 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: ShellExecute and run WordPad.exe ?? Pin
Nish Nishant11-Mar-02 17:13
sitebuilderNish Nishant11-Mar-02 17:13 
AnswerRe: ShellExecute and run WordPad.exe ?? Pin
Lim Bio Liong11-Mar-02 17:30
Lim Bio Liong11-Mar-02 17:30 
GeneralKnown issues with MoveMemory() in XP Pin
11-Mar-02 15:52
suss11-Mar-02 15:52 
GeneralRe: Known issues with MoveMemory() in XP Pin
Tim Smith11-Mar-02 17:08
Tim Smith11-Mar-02 17:08 
GeneralCopy Assignment :: C++ Pin
valikac11-Mar-02 15:42
valikac11-Mar-02 15:42 
GeneralRe: Copy Assignment :: C++ Pin
Paul M Watt11-Mar-02 17:29
mentorPaul M Watt11-Mar-02 17:29 
GeneralRe: Copy Assignment :: C++ Pin
valikac11-Mar-02 18:51
valikac11-Mar-02 18:51 
GeneralFixed! Pin
valikac11-Mar-02 19:11
valikac11-Mar-02 19:11 
Okay. I got it to work. This is such a "minor" problem. In fact, it is my carelessness.

Here is the new revised working code:

code:
-------------------------------------------------------------------------
void CSList::cloneList(const CSList &rSourceList)
{
cout << "\nCheck0a";

cout << "\nrSourcelist->nodeCnt = " << rSourceList.nodeCnt;

nodeCnt = rSourceList.nodeCnt;

cout << "\nnodeCnt = " << nodeCnt;

cout << "\nCheck0b";

try
{
pOriginNode = new CSListNode;
}

catch (bad_alloc &dmaError)
{
cerr << "\nError: " << dmaError.what()
<< "\nPress any key to close program";

cin.ignore(256, '\n');
cin.clear();

exit(1);
}

pOriginNode->eData = rSourceList.pOriginNode->eData;

CSListNode *pNewNode = pOriginNode;

cout << "\nCheck 1";

for (CSListNode *pTraverse = rSourceList.pOriginNode->next; pTraverse != 0; pTraverse = pTraverse->next)
{
try
{
pNewNode->next = new CSListNode;
}

catch (bad_alloc &dmaError)
{
cerr << "\nError: " << dmaError.what()
<< "\nPress any key to close program";

cin.ignore(256, '\n');
cin.clear();

exit(1);
}

pNewNode = pNewNode->next;
pNewNode->eData = pTraverse->eData;
}

cout << "\nCheck2";

pNewNode->next = 0;
}
------------------------------------------------------------------------

The change was:

------------------------------------------------------------------------

try
{
pOriginNode = new CSListNode;
}

catch (bad_alloc &dmaError)
{
cerr << "\nError: " << dmaError.what()
<< "\nPress any key to close program";

cin.ignore(256, '\n');
cin.clear();

exit(1);
}
------------------------------------------------------------------------

I found out when I looked over the constructor. I found that there were nothing initializing pOriginNode. I then looked at the code for inserting. I saw that if CMyList was empty (pOriginNode == 0), the pOriginNode = new CMyList.

Thanks.
-----------------------

One last related question. Is it good practice to set *all* deleted pointers to right after deleting them?

Kuphryn
GeneralTrying to Find = in a CString Pin
11-Mar-02 14:57
suss11-Mar-02 14:57 
GeneralRe: Trying to Find = in a CString Pin
jafrazee11-Mar-02 15:53
jafrazee11-Mar-02 15:53 
GeneralRe: Trying to Find = in a CString Pin
Nish Nishant11-Mar-02 17:15
sitebuilderNish Nishant11-Mar-02 17:15 
GeneralRe: Trying to Find = in a CString Pin
12-Mar-02 0:26
suss12-Mar-02 0:26 
GeneralRe: Trying to Find = in a CString Pin
12-Mar-02 0:39
suss12-Mar-02 0:39 
Generalnebulous TRACE output Pin
moredip11-Mar-02 13:37
moredip11-Mar-02 13:37 
GeneralRe: nebulous TRACE output Pin
Shog911-Mar-02 14:07
sitebuilderShog911-Mar-02 14:07 
GeneralRe: nebulous TRACE output Pin
Roger Allen11-Mar-02 22:12
Roger Allen11-Mar-02 22:12 
GeneralRe: nebulous TRACE output Pin
moredip12-Mar-02 5:23
moredip12-Mar-02 5:23 
GeneralRe: nebulous TRACE output Pin
Stephen C. Steel12-Mar-02 11:58
Stephen C. Steel12-Mar-02 11:58 
GeneralRe: nebulous TRACE output Pin
Stephen C. Steel12-Mar-02 12:12
Stephen C. Steel12-Mar-02 12:12 
GeneralRe: nebulous TRACE output Pin
moredip12-Mar-02 12:20
moredip12-Mar-02 12:20 
Questiontoo simple to work? Pin
11-Mar-02 13:18
suss11-Mar-02 13:18 
AnswerRe: too simple to work? Pin
Joaquín M López Muñoz11-Mar-02 20:14
Joaquín M López Muñoz11-Mar-02 20:14 
GeneralRe: too simple to work? Pin
12-Mar-02 4:47
suss12-Mar-02 4:47 
GeneralRe: too simple to work? Pin
Atila12-Mar-02 5:25
Atila12-Mar-02 5:25 
GeneralRe: too simple to work? Pin
12-Mar-02 5:27
suss12-Mar-02 5:27 

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.