为什么用cstring提示 error C2065: 'Cstring' : 未宣告的識別項

drizztguai 2009-01-28 02:02:02
第一次学习vc++

vista所以用的vs2008

档案->新增->专案->mfc应用程式->名字->下一步->单一文件界面->完成


然后找到Chello1View  这里奇怪的是我的类别搜寻器是没有的,就是没有filter... 很不方便,在vs2008里怎么调出来哦?

// Chello1View 描繪

void Chello1View::OnDraw(CDC* pDC)
{
Chello1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

int num[5]={2,4,6,8,10};
int sum=0;
for(int i=0;i<=4;i++){
sum+=num[i];
}
Cstring strNum;
strNum.Format("%d",sum);
pDc->TextOut(0,0,"Sum is ",+strNum);

// TODO: 在此加入原生資料的描繪程式碼
}

然后调试,好多错误:
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(59) : error C2065: 'Cstring' : 未宣告的識別項
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(59) : error C2146: 語法錯誤 : 遺漏 ';' (在識別項 'strNum' 之前)
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(59) : error C2065: 'strNum' : 未宣告的識別項
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(60) : error C2065: 'strNum' : 未宣告的識別項
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(60) : error C2228: '.Format' 的左邊必須有類別/結構/等位
1> 型別為 ''unknown-type''
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(61) : error C2065: 'pDc' : 未宣告的識別項
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(61) : error C2227: '->TextOutW' 的左邊必須指向類別/結構/等位/泛型型別
1> 型別為 ''unknown-type''
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(61) : error C2065: 'strNum' : 未宣告的識別項


谢谢哦!~
...全文
900 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
一条晚起的虫 2009-01-28
  • 打赏
  • 举报
回复
//应该对了
void Chello1View::OnDraw(CDC* pDC)
{
Chello1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

// TODO: 在此加入原生資料的描繪程式碼
int num[5]={2,4,6,8,10};
int sum=0;
for(int i=0;i<=4;i++){
sum+=num[i];
}
CString strNum;
strNum.Format(_T("Sum is %d"), sum);
pDC->TextOutW(0, 0, strNum);
}
一条晚起的虫 2009-01-28
  • 打赏
  • 举报
回复
void Chello1View::OnDraw(CDC* pDC)
{
Chello1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

// TODO: 在此加入原生資料的描繪程式碼
int num[5]={2,4,6,8,10};
int sum=0;
for(int i=0;i<=4;i++){
sum+=num[i];
}
Cstring strNum;
strNum.Format(_T("Sum is %d"), sum);
pDc->TextOutW(0, 0, strNum);


}
fishion 2009-01-28
  • 打赏
  • 举报
回复
void Chello1View::OnDraw(CDC* pDC)
{
Chello1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

int num[5]={2,4,6,8,10};
int sum=0;
for(int i=0;i <=4;i++){
sum+=num[i];
}
CString strNum;
strNum.Format(_T("%d"),sum);
pDC->TextOut(0,0,_T("Sum is ,")+strNum);

// TODO: 在此加入原生資料的描繪程式碼
}
fishion 2009-01-28
  • 打赏
  • 举报
回复
void Chello1View::OnDraw(CDC* pDC)
{
Chello1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

int num[5]={2,4,6,8,10};
int sum=0;
for(int i=0;i <=4;i++){
sum+=num[i];
}
CString strNum;
strNum.Format(_T("%d"),sum);
pDC->TextOut(0,0,_T("Sum is ,")+strNum);

// TODO: 在此加入原生資料的描繪程式碼
}
fishion 2009-01-28
  • 打赏
  • 举报
回复
void Chello1View::OnDraw(CDC* pDC)
{
Chello1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);

int num[5]={2,4,6,8,10};
int sum=0;
for(int i=0;i<=4;i++){
sum+=num[i];
}
Cstring strNum;
strNum.Format(_T("%d"),sum);
pDC->TextOut(0,0,_T("Sum is "),+strNum);

// TODO: 在此加入原生資料的描繪程式碼
}

fishion 2009-01-28
  • 打赏
  • 举报
回复
pDc->TextOut(0,0,"Sum is ",+strNum);

pDC大写C
drizztguai 2009-01-28
  • 打赏
  • 举报
回复
我去死..

应该是pDC 还是大小写错了..

不过还是不行 - -;

c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(60) : error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : 無法將參數 1 從 'const char [3]' 轉換成 'const wchar_t *'
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> 指向的型別沒有相關; 轉換必須有 reinterpret_cast、C-Style 轉換或函式樣式轉換
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(61) : error C2678: 二元運算子 '+' : 找不到使用左方運算元型別 'const char [8]' 的運算子 (或是沒有可接受的轉換)
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(654): 可能是 'ATL::CSimpleStringT<BaseType,t_bMFCDLL> ATL::CSimpleStringT<BaseType,t_bMFCDLL>::operator +(const ATL::CSimpleStringT<BaseType,t_bMFCDLL> &,const ATL::CSimpleStringT<BaseType,t_bMFCDLL> &)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> t_bMFCDLL=true
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(665): 或 'ATL::CSimpleStringT<BaseType,t_bMFCDLL> ATL::CSimpleStringT<BaseType,t_bMFCDLL>::operator +(const ATL::CSimpleStringT<BaseType,t_bMFCDLL> &,const wchar_t *)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> t_bMFCDLL=true
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlsimpstr.h(676): 或 'ATL::CSimpleStringT<BaseType,t_bMFCDLL> ATL::CSimpleStringT<BaseType,t_bMFCDLL>::operator +(const wchar_t *,const ATL::CSimpleStringT<BaseType,t_bMFCDLL> &)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> t_bMFCDLL=true
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2033): 或 'ATL::CStringT<BaseType,StringTraits> ATL::CStringT<BaseType,StringTraits>::operator +(const ATL::CStringT<BaseType,StringTraits> &,const ATL::CStringT<BaseType,StringTraits> &)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2042): 或 'ATL::CStringT<BaseType,StringTraits> ATL::CStringT<BaseType,StringTraits>::operator +(const ATL::CStringT<BaseType,StringTraits> &,const wchar_t *)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2051): 或 'ATL::CStringT<BaseType,StringTraits> ATL::CStringT<BaseType,StringTraits>::operator +(const wchar_t *,const ATL::CStringT<BaseType,StringTraits> &)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2060): 或 'ATL::CStringT<BaseType,StringTraits> ATL::CStringT<BaseType,StringTraits>::operator +(const ATL::CStringT<BaseType,StringTraits> &,wchar_t)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2070): 或 'ATL::CStringT<BaseType,StringTraits> ATL::CStringT<BaseType,StringTraits>::operator +(const ATL::CStringT<BaseType,StringTraits> &,char)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2080): 或 'ATL::CStringT<BaseType,StringTraits> ATL::CStringT<BaseType,StringTraits>::operator +(wchar_t,const ATL::CStringT<BaseType,StringTraits> &)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\cstringt.h(2090): 或 'ATL::CStringT<BaseType,StringTraits> ATL::CStringT<BaseType,StringTraits>::operator +(char,const ATL::CStringT<BaseType,StringTraits> &)' [使用與引數相關的查閱找到]
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> 當嘗試符合引數清單 '(const char [8], CString)' 時
1>已將建置記錄儲存於 "file://c:\Users\calm\Documents\Visual Studio 2008\Projects\hello1\hello1\Debug\BuildLog.htm"
1>hello1 - 2 個錯誤,0 個警告
========== 建置: 0 成功、1 失敗、0 最新、0 略過 ==========
drizztguai 2009-01-28
  • 打赏
  • 举报
回复
谢谢额!~
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(61) : error C2065: 'pDc' : 未宣告的識別項
1>c:\users\calm\documents\visual studio 2008\projects\hello1\hello1\hello1view.cpp(61) : error C2227: '->TextOutW' 的左邊必須指向類別/結構/等位/泛型型別

还有错误哦!~

还有能不能告诉我 怎么调出 filter...  ~~

谢谢~~~
一条晚起的虫 2009-01-28
  • 打赏
  • 举报
回复
CString
一条晚起的虫 2009-01-28
  • 打赏
  • 举报
回复
CSting,不是Cstring, S大写
fishion 2009-01-28
  • 打赏
  • 举报
回复
CString

16,473

社区成员

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

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

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