• <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>

            小明思考

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

            再談從vc6遷移到vs2005

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

             

               作為C++編譯器,從vc6到vc8最大的調整就是對C++標準的支持更好了。
               我發(fā)現(xià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)的開始與結束期間有效。

            b.string實現(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.更嚴格的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更加嚴格的要求程序員在類型前面加上typename以避免歧義

            d.不允許默認的int類型

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

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

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

            vc8不支持默認返回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  回復  更多評論   

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

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

            # re: cf   回復  更多評論   

            2006-03-13 15:12 by 小明
            about b 這個確實跟編譯器沒有關系

            但是由于stl的重要性,所以我也把這點列了上去。vc6的stl實現(xiàn)跟vc8差異還是很大的。因為我在看見的工程里面發(fā)現(xiàn)了很多char *p = s.begin(); 這樣的寫法,所以我不得不去改他們。

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

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

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

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

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

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

            把string轉為char *,就為了傳入一些Windows API中去。
            用c_str()沒有問題,stl標準規(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  回復  更多評論   

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

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

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

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

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

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

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

            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  回復  更多評論   

            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

            # 關于2005編譯的問題  回復  更多評論   

            2008-06-19 16:58 by 學習者
            #include "stdafx.h"
            #include <hash_map>
            using namespace std;
            typedef hash_multimap<int,int> HashMap_ElePattern;
            在一個新建的文件里我就寫了這幾行,出現(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  回復  更多評論   

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

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

            2009-05-03 12:48 by 創(chuàng)意產(chǎn)品
            學習了,謝謝
            欧美精品丝袜久久久中文字幕| 久久黄视频| 996久久国产精品线观看| 久久久久久亚洲精品成人| 伊人久久综在合线亚洲2019| 婷婷久久综合九色综合九七| 青草国产精品久久久久久| 国产精品99久久久久久宅男| 亚洲国产精品一区二区久久hs | 99久久精品影院老鸭窝| 久久精品国产精品亜洲毛片| 亚洲午夜久久久影院| 9191精品国产免费久久| 久久99精品久久久大学生| 久久久久人妻精品一区三寸蜜桃| 97精品伊人久久大香线蕉| 国产精品日韩欧美久久综合| 亚洲色欲久久久综合网东京热| 国产精品美女久久久久AV福利| 人妻精品久久久久中文字幕一冢本| 精品国产综合区久久久久久 | 2021国内久久精品| 国内精品伊人久久久久影院对白 | 伊人久久久AV老熟妇色| 久久综合久久鬼色| 国产2021久久精品| 久久久久久久尹人综合网亚洲| 色狠狠久久综合网| 精品人妻伦一二三区久久| 93精91精品国产综合久久香蕉| 国产精品久久久久aaaa| AV无码久久久久不卡网站下载| 少妇人妻88久久中文字幕| 久久久久av无码免费网| 亚洲精品美女久久久久99小说| 久久久WWW免费人成精品| 久久人妻少妇嫩草AV蜜桃| 久久婷婷五月综合色99啪ak| 久久久99精品成人片中文字幕| 久久精品无码一区二区三区免费 | 亚洲国产成人久久一区WWW|