📄 subject_55137.htm
字号:
<p>
序号:55137 发表者:鹏程 发表日期:2003-10-07 00:46:00
<br>主题:请教关于MFC集合类
<br>内容:请问要使用CStringLidt链表对象,需要包含什么头文件?<BR><BR><BR><BR><BR><BR><BR>
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:tjhe 回复日期:2003-10-07 09:32:13
<br>内容:CStringList //Afxcoll.h<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:鹏程 回复日期:2003-10-07 10:42:21
<br>内容:谢谢。但是包含了Afxcoll.h也不行,为什么?<BR><BR><BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:jackyxio 回复日期:2003-10-07 10:57:58
<br>内容:鹏程,麻烦把问题说清楚!!<BR><BR>一般来说,包含了头文件就应该可以了。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:鹏程 回复日期:2003-10-07 11:17:00
<br>内容:谢谢!<BR>我在CEditorDoc类中使用了CStringLidt对象:<BR><BR>// editorDoc.h : interface of the CEditorDoc class<BR>//<BR>/////////////////////////////////////////////////////////////////////////////<BR><BR>#if !defined(AFX_EDITORDOC_H__AB9531E2_8D26_42E6_898F_F0DB4D77AE58__INCLUDED_)<BR>#define AFX_EDITORDOC_H__AB9531E2_8D26_42E6_898F_F0DB4D77AE58__INCLUDED_<BR><BR>#if _MSC_VER > 1000<BR>#pragma once<BR>#endif // _MSC_VER > 1000<BR><BR>////////////////////////////////////////////////<BR>#include "AFXCOLL.h" //包含文件<BR><BR><BR><BR><BR>class CEditorDoc : public CDocument<BR>{<BR>protected: // create from serialization only<BR> CEditorDoc();<BR> DECLARE_DYNCREATE(CEditorDoc)<BR> <BR>// Attributes<BR>public:<BR> CStringLidt lines; //定义数据成员<BR> int nLineNum;<BR><BR>// Operations<BR>public:<BR><BR>// Overrides<BR> // ClassWizard generated virtual function overrides<BR> //{{AFX_VIRTUAL(CEditorDoc)<BR> public:<BR> virtual BOOL OnNewDocument();<BR> virtual void Serialize(CArchive& ar);<BR> //}}AFX_VIRTUAL<BR><BR>// Implementation<BR>public:<BR> virtual ~CEditorDoc();<BR>#ifdef _DEBUG<BR> virtual void AssertValid() const;<BR> virtual void Dump(CDumpContext& dc) const;<BR>#endif<BR><BR>protected:<BR><BR>// Generated message map functions<BR>protected:<BR> //{{AFX_MSG(CEditorDoc)<BR> // NOTE - the ClassWizard will add and remove member functions here.<BR> // DO NOT EDIT what you see in these blocks of generated code !<BR> //}}AFX_MSG<BR> DECLARE_MESSAGE_MAP()<BR>};<BR><BR>/////////////////////////////////////////////////////////////////////////////<BR><BR>//{{AFX_INSERT_LOCATION}}<BR>// Microsoft Visual C++ will insert additional declarations immediately before the previous line.<BR><BR>#endif // !defined(AFX_EDITORDOC_H__AB9531E2_8D26_42E6_898F_F0DB4D77AE58__INCLUDED_)<BR><BR>然后初始化变量:<BR><BR>BOOL CEditorDoc::OnNewDocument()<BR>{<BR> if (!CDocument::OnNewDocument())<BR> return FALSE;<BR><BR> // TODO: add reinitialization code here<BR> // (SDI documents will reuse this document)<BR> nLineNum=0; //数据成员初始化<BR> POSITION pos;<BR> pos=lines.GetHeadPosition();<BR> while(pos!=NULL)<BR> {<BR> ((CString)lines.GetNext(pos)).Empty();<BR> }<BR> lines.RemoveAll();<BR><BR> return TRUE;<BR>}<BR><BR>结果出现编译信息如下:<BR><BR>--------------------Configuration: editor - Win32 Debug--------------------<BR>Compiling resources...<BR>Compiling...<BR>StdAfx.cpp<BR>Compiling...<BR>editor.cpp<BR>e:\vc_mfc\editor\editordoc.h(26) : error C2146: syntax error : missing ';' before identifier 'lines'<BR>e:\vc_mfc\editor\editordoc.h(26) : error C2501: 'CStringLidt' : missing storage-class or type specifiers<BR>e:\vc_mfc\editor\editordoc.h(26) : error C2501: 'lines' : missing storage-class or type specifiers<BR>editorDoc.cpp<BR>e:\vc_mfc\editor\editordoc.h(26) : error C2146: syntax error : missing ';' before identifier 'lines'<BR>e:\vc_mfc\editor\editordoc.h(26) : error C2501: 'CStringLidt' : missing storage-class or type specifiers<BR>e:\vc_mfc\editor\editordoc.h(26) : error C2501: 'lines' : missing storage-class or type specifiers<BR>E:\vc_MFC\editor\editorDoc.cpp(49) : error C2065: 'lines' : undeclared identifier<BR>E:\vc_MFC\editor\editorDoc.cpp(49) : error C2228: left of '.GetHeadPosition' must have class/struct/union type<BR>E:\vc_MFC\editor\editorDoc.cpp(52) : error C2228: left of '.GetNext' must have class/struct/union type<BR>E:\vc_MFC\editor\editorDoc.cpp(52) : error C2228: left of '.Empty' must have class/struct/union type<BR>E:\vc_MFC\editor\editorDoc.cpp(54) : error C2228: left of '.RemoveAll' must have class/struct/union type<BR>editorView.cpp<BR>e:\vc_mfc\editor\editordoc.h(26) : error C2146: syntax error : missing ';' before identifier 'lines'<BR>e:\vc_mfc\editor\editordoc.h(26) : error C2501: 'CStringLidt' : missing storage-class or type specifiers<BR>e:\vc_mfc\editor\editordoc.h(26) : error C2501: 'lines' : missing storage-class or type specifiers<BR>MainFrm.cpp<BR>Generating Code...<BR>Error executing cl.exe.<BR>Creating browse info file...<BR><BR>editor.exe - 14 error(s), 0 warning(s)<BR><BR>为什么包含了文件#include "AFXCOLL.h"也不行呢???<BR><BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:tjhe 回复日期:2003-10-07 11:50:04
<br>内容:是CStringList还是CStringLidt?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:鹏程 回复日期:2003-10-07 12:02:51
<br>内容:谢谢了,是我写错了,没看出来。<BR><BR><BR><BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -