// matlightView.h : interface of the CMatlightView class
//
/////////////////////////////////////////////////////////////////////////////
#include <afxtempl.h>
#include <afxcoll.h>
typedef struct node
{
int x;
int y;
int z;
int h;
int g;
}Node;
typedef struct arry
{
int n;
CArray<Node,Node&> m_arry;
}Drill;
class CMatlightView : public CView
{
protected: // create from serialization only
CMatlightView();
DECLARE_DYNCREATE(CMatlightView)// Attributes
public:
CMatlightDoc* GetDocument();
BOOL m_bPrinting; CPalette m_GLPalette; // Logical Palette
HDC m_hDC;// OpenGL Attributes
HGLRC m_hRC;// Operations
public:
 CArray<Drill ,Drill&> m_bore;
public:
 
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMatlightView)
public:
virtual void OnDraw(CDC* pDC);  // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnInitialUpdate();
virtual BOOL DestroyWindow();
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
//}}AFX_VIRTUAL

// Implementation
public:
virtual ~CMatlightView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endifprotected:
void PrintSettings(CDC* pDC);
void InitializePalette(HDC hDC);// Generated message map functions
protected:
//{{AFX_MSG(CMatlightView)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg BOOL OnQueryNewPalette();
afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
afx_msg void OnFileNew();
afx_msg void OnFileOpen();
afx_msg void OnFileSaveAs();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG  // debug version in matlightView.cpp
inline CMatlightDoc* CMatlightView::GetDocument()
   { return (CMatlightDoc*)m_pDocument; }
#endif/////////////////////////////////////////////////////////////////////////////
void CMatlightView::OnFileOpen() 
{
// TODO: Add your command handler code here
char *szFilter="Text Files(*.txt)|*.text|All Files(*.*)|*.*||";
CFileDialog dig(TRUE,"txt",TEXT("data.txt"),
            OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter);
dig.DoModal();
CString filepath=dig.GetPathName();
CStdioFile file;
file.Open(filepath,CFile::modeCreate|CFile::typeText);
int number1;
int number2;
Node node;
Drill  drill;
file.Read(&number1,sizeof(int));
m_bore.SetSize(number1);
for(int i=0;i<number1;i++)
{
file.Read(&number2,sizeof(int));
        file.Read(&node,sizeof(Node));
drill.n=number2;
drill.m_arry.SetSize(number2);
for(int j=0;j<number2;i++)
{
file.Read(&node,sizeof(Node));
drill.m_arry[i]=node;
}
    m_bore.Add(drill);
}
file.Close();
    Invalidate(); 
}
//////////////////////////////////
/////////////////////////////////
编译的时候.出错信息是:
crosoft Visual Studio\VC98\MFC\INCLUDE\afxtempl.h(443) : error C2582: 'arry' : 'operator =' function is unavailable
        D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxtempl.h(1566) : while compiling class-template member function 'void __thiscall CArray<struct arry,struct arry &>::SetAtGrow(int,struct arry &)'
Generating Code...
我的目的是想从data.txt文本文件中读取数据
文件中的数据格式为:
number     //下面有number行.
n1  x1 y1 z1 h1 g1  x2 y2 z2 h2 g2.....//有n1个(x y z h g)  
n2  x y z h g  x y z h g...............
....
..........
.........