新手学习中问题,请大虾指教

firehan 2010-08-06 11:35:20
在代码中:
class CSingleView : public CView
{
protected: // create from serialization only
CSingleView();
DECLARE_DYNCREATE(CSingleView)

// Attributes
public:
CSingleDoc* GetDocument();

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSingleView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL

// Implementation
public:
string str; virtual ~CSingleView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
//{{AFX_MSG(CSingleView)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

红字部分是自己添加的一个变量声明,其余代码是mfc框架生成的。
加上代码就报错:
error C2146: syntax error : missing ';' before identifier 'str'
error C2501: 'string' : missing storage-class or type specifiers
error C2501: 'str' : missing storage-class or type specifiers

本人刚在学习中,请赐教
...全文
62 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
firehan 2010-08-06
  • 打赏
  • 举报
回复
可以了,谢谢各位老大。。
zgsdzhaolanxiang1 2010-08-06
  • 打赏
  • 举报
回复
#include <string>
using namespace std;
Eleven 2010-08-06
  • 打赏
  • 举报
回复
#include <string>
using namespace std;
ColdMooon 2010-08-06
  • 打赏
  • 举报
回复
要写CString
jhayumu 2010-08-06
  • 打赏
  • 举报
回复
string 没有声明, 加个头文件
firehan 2010-08-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 fandh 的回复:]
加一个:#include <string>
[/Quote]

加了还是报同样的错误
fandh 2010-08-06
  • 打赏
  • 举报
回复
加一个:#include <string>
creamymami 2010-08-06
  • 打赏
  • 举报
回复
原来酱紫。。。深受mfc毒害的初学者飘过。。。
zjz800800 2010-08-06
  • 打赏
  • 举报
回复
string和CString 是分别的两个字符串的类,CString是mfc的,而string是标准摸板库的。
creamymami 2010-08-06
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 fangongdalu7148 的回复:]
#include <string>
using namespace std;
[/Quote]

弱弱问一下。。。string是什么东西?不是CString?- -

16,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧