class CPoint3D
{
public:
int m_x, m_y, m_z;
CPoint3D( )
{
m_x = m_y = m_z = 0;
}
CPoint3D(int x, int y, int z)
{
m_x = x; m_y = y; m_z = z;
}
BOOL operator== (const CPoint3D &point) const
{
return (m_x == point.m_x && m_y == point.m_y && m_z == point.m_z);
}
};
void main()
{
using namespace std;
CList <CPoint3D, CPoint3D&> list;
list.AddTail(CPoint3D(3, 4, 2));
list.AddTail(CPoint3D(1, 2, 3));
POSITION pos = list.Find(CPoint3D(1, 2, 3));
if(pos)
{
CPoint3D point = list.GetAt(pos);
cout << point.m_x << ", " << point.m_y << ", " << point.m_z << endl;
}
}
class CDrawDoc : public CDocument
{
...
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDrawDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
virtual void DeleteContents();
//}}AFX_VIRTUAL
// Implementation
public:
CTypedPtrList<CObList, CStroke*> m_strokeList;
virtual ~CDrawDoc();
...
};
void CDrawDoc::Serialize(CArchive& ar)
{
m_strokeList.Serialize(ar);
/* if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}*/
}
...
void CDrawDoc::DeleteContents()
{
// TODO: Add your specialized code here and/or call the base class
// {
while (!m_strokeList.IsEmpty())
delete m_strokeList.RemoveHead();
// }
CDocument::DeleteContents();
}
void CDrawView::OnDraw(CDC* pDC)
{
CDrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
POSITION pos = pDoc->m_strokeList.GetHeadPosition();
while (pos != NULL)
{
CStroke* pStroke = pDoc->m_strokeList.GetNext(pos);
...
}
}
...
void CDrawView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
// {
CDrawDoc *pDoc = GetDocument();
m_pCurrentStroke = new CStroke(m_nPenThickness, m_PenColor);
pDoc->m_strokeList.AddTail(m_pCurrentStroke);
pDoc->SetModifiedFlag();
SetCapture();
m_ptPrev = point;
// }
CView::OnLButtonDown(nFlags, point);
}
...