• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            小明思考

            高性能服務(wù)器端計(jì)算
            posts - 70, comments - 428, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            再談從vc6遷移到vs2005

            Posted on 2006-03-13 11:03 小明 閱讀(21950) 評論(12)  編輯 收藏 引用 所屬分類: C/C++

             

               作為C++編譯器,從vc6到vc8最大的調(diào)整就是對C++標(biāo)準(zhǔn)的支持更好了。
               我發(fā)現(xiàn)的幾點(diǎn)不同。

            a. For 循環(huán)的聲明

                  Vc6: for(int i<0;i<100;++i){}; j = i;   (ok)

            Vc8: for(int i<0;i<100;++i){}; j = i;   (illegal)

                  int i; for(i<0;i<100;++i){}; j = i;   (ok)

            Vc8中的for循環(huán)中變量的有效期僅僅在for 循環(huán)的開始與結(jié)束期間有效。

            b.string實(shí)現(xiàn)
               

            Vc6: string s; char *p = s.begin(); (ok)

            Vc8: string s; char *p = s.begin(); (illegal)

                 string s; char *p = const_cast<char *>(s.c_str()); (ok)

            在vc6中,string::iterator被定義為char *,但是vc8中不是

            c.更嚴(yán)格的typename聲明的需要

            Vc6:

            template<class T>

            class Test

            {

            public:

            typedef map<T,T> mymap;

                  mymap::iterator mymap_iter;

            }; (ok)

            Vc8:

            template<class T>

            class Test

            {

            public:

                  typedef map<T,T> mymap;

                  mymap::iterator mymap_iter;

            };     (illegal)

            typename mymap::iterator mymap_iter;(ok)

            vc8更加嚴(yán)格的要求程序員在類型前面加上typename以避免歧義

            d.不允許默認(rèn)的int類型

            Vc6: fun() { return 0;} (ok)

            Vc8: fun() { return 0;} (illegal)

            int fun() { return 0;} (ok)

            vc8不支持默認(rèn)返回int類型

            e.typedef必須是public才能被外界訪問到

            Vc6:

            Class Test

            {

                  typedef int iterator;

            };

            Test::iterator i; (ok)

            Vc8:

            Class Test

            {

                  typedef int iterator;

            };

            Test::iterator i; (illegal)

             

            Class Test

            {

            public:

                  typedef int iterator;

            };

            Test::iterator i; (ok)

            附錄:一些資源(From msdn)

            Overviews:

            Moving from 6.0 to 7.1:

            Moving from 7.1 to 8.0:

            Feedback

            # re: 再談從vc6遷移到vs2005  回復(fù)  更多評論   

            2006-03-13 14:06 by cf
            about b
            這個(gè)應(yīng)該是庫實(shí)現(xiàn)的不同,而非編譯器的吧,呵呵

            c++標(biāo)準(zhǔn)規(guī)定template class basic_string的iterator是
            typedef implementation defined iterator;
            這樣的,即使vc6附帶的pj庫有
            typedef char* iterator;
            這樣的定義,也不能認(rèn)為二者有必要聯(lián)系吧,換句話說,即便在vc6(with那個(gè)pj庫)中
            char *p = s.begin();
            能被編譯通過,這么些也是不妥當(dāng)?shù)模呛?/div>

            # re: cf   回復(fù)  更多評論   

            2006-03-13 15:12 by 小明
            about b 這個(gè)確實(shí)跟編譯器沒有關(guān)系

            但是由于stl的重要性,所以我也把這點(diǎn)列了上去。vc6的stl實(shí)現(xiàn)跟vc8差異還是很大的。因?yàn)槲以诳匆姷墓こ汤锩姘l(fā)現(xiàn)了很多char *p = s.begin(); 這樣的寫法,所以我不得不去改他們。

            # re: 再談從vc6遷移到vs2005  回復(fù)  更多評論   

            2006-03-13 17:11 by 沐楓網(wǎng)志
            const_cast<char *>(s.c_str())
            這樣的用法,也很不妥當(dāng)喲。--估計(jì)這就是當(dāng)初工程師之所以使用begin()的原因。

            建議,如果是為了遍歷字串,使用string::iterator p = s.begin();
            或者 s[n],等方式來使用字符串。

            這樣,照樣可以 *p++,也照樣可以 *p = 'A',可以s[10]='A',可以char a = s[10]。
            但是s.c_str()就比較玄了……

            # re: 沐楓網(wǎng)志  回復(fù)  更多評論   

            2006-03-13 17:34 by 小明
            他們這樣用,并不是為了遍歷,很少有人需要遍歷字符串,畢竟string有很多成員函數(shù)可以幫助做到。

            把string轉(zhuǎn)為char *,就為了傳入一些Windows API中去。
            用c_str()沒有問題,stl標(biāo)準(zhǔn)規(guī)定的,保持string和char *的可兼容。

            經(jīng)常是這樣用的
            string str;
            str.resize(255);
            ::RegSetValueEx(hKey, REGVAL_CREDENTIAL_CIPHERKEY, NULL, REG_BINARY, const_cast<char *>(str.c_str()) , str.size());

            # re: 再談從vc6遷移到vs2005  回復(fù)  更多評論   

            2006-03-13 22:01 by fiestay
            不錯(cuò).
            不過現(xiàn)在還沒有幾乎將項(xiàng)目轉(zhuǎn)到2005上,而且感覺2005很容易出問題.有時(shí)候編譯運(yùn)行時(shí),會(huì)提示找不到MFC8.0.dll,真是faint~~

            # re: 再談從vc6遷移到vs2005  回復(fù)  更多評論   

            2006-03-14 10:26 by 1234
            VS 2005出得有點(diǎn)讓人失望,Bug太多了,MS應(yīng)該推遲VS2005的發(fā)布

            順便問一下樓主,您知道如何編程程序控制顯卡的雙輸出么,就是說希望將一個(gè)界面輸出到主顯示器,另一個(gè)界面輸出到從顯示器. 謝謝

            # re: 再談從vc6遷移到vs2005  回復(fù)  更多評論   

            2006-03-15 12:18 by stone
            都常遇到哪些Bug?

            # re: 再談從vc6遷移到vs2005  回復(fù)  更多評論   

            2006-07-13 15:23 by jakeinus
            when I open a vc project in vc2005 and I debug the program,it has the following error,please tell me why,Thanks.

            Error 1 error C2146: syntax error : missing ';' before identifier 'PVOID64' c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h 222
            Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h 222
            Error 3 error C2146: syntax error : missing ';' before identifier 'Buffer' c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h 5940
            Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h 5940
            Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files\microsoft visual studio 8\vc\platformsdk\include\winnt.h 5940




            I appreciate your help.


            # re: 再談從vc6遷移到vs2005  回復(fù)  更多評論   

            2006-07-13 15:45 by 小明
            @jakeinus

            I can't reshow the message in my vs2005.
            Can you send me some sample code?
            mailto : littlelight80@hotmail.com

            # 關(guān)于2005編譯的問題  回復(fù)  更多評論   

            2008-06-19 16:58 by 學(xué)習(xí)者
            #include "stdafx.h"
            #include <hash_map>
            using namespace std;
            typedef hash_multimap<int,int> HashMap_ElePattern;
            在一個(gè)新建的文件里我就寫了這幾行,出現(xiàn)了下面的問題:
            error C2143: syntax error : missing ';' before '<'
            error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

            # re: 再談從vc6遷移到vs2005  回復(fù)  更多評論   

            2008-09-21 18:11 by jingle
            you can add "using namespace stdext;"

            # re: 再談從vc6遷移到vs2005  回復(fù)  更多評論   

            2009-05-03 12:48 by 創(chuàng)意產(chǎn)品
            學(xué)習(xí)了,謝謝
            久久精品亚洲一区二区三区浴池 | 无码人妻少妇久久中文字幕蜜桃| 伊人久久大香线蕉综合热线| 久久久老熟女一区二区三区| 国产91久久综合| 一级做a爰片久久毛片毛片| 一本久久a久久精品亚洲| 国产成人综合久久综合| 精品久久久一二三区| 热99re久久国超精品首页| 精品国产日韩久久亚洲| 国产福利电影一区二区三区久久老子无码午夜伦不 | 日本WV一本一道久久香蕉| 亚洲第一极品精品无码久久| 狠狠久久综合| 青青青青久久精品国产| 伊人久久大香线蕉av一区| 狠狠人妻久久久久久综合蜜桃| 久久午夜福利电影| 久久精品国产91久久麻豆自制 | 精品国产青草久久久久福利| 7国产欧美日韩综合天堂中文久久久久| 久久人人青草97香蕉| 国内精品久久久久久久亚洲| 国产精品久久久久jk制服| 中文字幕日本人妻久久久免费 | 久久久久久青草大香综合精品| 久久婷婷综合中文字幕| 国产精品美女久久久m| 亚洲午夜久久久久久久久电影网| 亚洲婷婷国产精品电影人久久| 久久99精品久久久久久野外 | 久久精品水蜜桃av综合天堂| 久久人人爽人人人人片av| 一本一道久久a久久精品综合| 久久影院午夜理论片无码 | 久久99九九国产免费看小说| 国产精品久久久久久久久久影院| 香蕉久久夜色精品国产尤物| 亚洲天堂久久久| 无码人妻精品一区二区三区久久|