第一次学习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' : 未宣告的識別項
谢谢哦!~

解决方案 »

  1.   

    CSting,不是Cstring, S大写
      

  2.   

    谢谢额!~
    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...  ~~谢谢~~~
      

  3.   

    我去死..应该是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 略過 ==========
      

  4.   

    pDc->TextOut(0,0,"Sum is ",+strNum);pDC大写C
      

  5.   

    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: 在此加入原生資料的描繪程式碼
    }
      

  6.   

    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: 在此加入原生資料的描繪程式碼 

      

  7.   

    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: 在此加入原生資料的描繪程式碼 

      

  8.   

    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);
    }
      

  9.   

    //应该对了
    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);
    }