CPtrList – 青春部落,流年似水 http://www.youthtribe.com 青春是一场远行,总记不起来时的路。 Fri, 26 Oct 2018 05:28:33 +0000 zh-CN hourly 1 https://wordpress.org/?v=6.1.6 CPtrList – 青春部落,流年似水 http://www.youthtribe.com/archives/1746 http://www.youthtribe.com/archives/1746#respond Thu, 25 Oct 2018 07:34:03 +0000 http://www.youthtribe.com/?p=1746 自己写原始的一个链表,还是很麻烦的,mfc是有一个很好用的类的。就是CPtrList,他就是存储多个指针的。

CPtrList添加指针,pItem是一个指针:

m_pSubjectItemList.AddTail(pItem);

 

CPtrList的遍历方法如下:

	POSITION pos = m_pSubjectItemList.GetHeadPosition();
	while (pos != NULL)
	{
		CSubjectItem * pOne = (CSubjectItem * )m_pSubjectItemList.GetNext(pos);
		if (pOne != NULL)
		{
			delete pOne;
		}
	}		
	m_pSubjectItemList.RemoveAll();
]]>
http://www.youthtribe.com/archives/1746/feed 0