INFO: Adding a CObList Object to Another CObList (98602)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++
    • Microsoft Visual C++, 32-bit Professional Edition
    • Microsoft Visual C++, 32-bit Enterprise Edition
    • Microsoft Visual C++, 32-bit Learning Edition

This article was previously published under Q98602
1.00 1.50 1.51 1.52 | 1.00 2.00 2.10 4.00 WINDOWS | WINDOWS NT kbprg
When the parameter to the AddHead() or AddTail() member functions of CObList specifies a pointer to an object derived from CObList, the functions add all the items specified in the argument object to the list. To add the CObList object to the list, the application must cast the CObList pointer to a CObject pointer.

In the CObList class, the AddHead() and AddTail() functions accept either a "CObject *" or a "CObList *" argument. When the functions receive a "CObList *", the functions add all the items in the specified list to the list. To add the list object to another list, cast the list pointer to a CObject pointer. The following sample code demonstrates the differences between these methods.

Sample Code



   // adds all of the CObject items contained in listSrc to listTarget
   listTarget.AddTail(&listSrc);

		


   // adds listSrc as a CObList object to listTarget
   listTarget.AddTail((CObject *)&listSrc);
		

SUMMARY


Modification Type:MajorLast Reviewed:12/11/2003
Keywords:kbCollectionClass kbinfo KB98602