• <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++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

            再談從vc6遷移到vs2005

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

             

               作為C++編譯器,從vc6到vc8最大的調(diào)整就是對(duì)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)的開(kāi)始與結(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才能被外界訪問(wèn)到

            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ù)  更多評(píng)論   

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

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

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

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

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

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

            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],等方式來(lái)使用字符串。

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

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

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

            把string轉(zhuǎn)為char *,就為了傳入一些Windows API中去。
            用c_str()沒(méi)有問(wèn)題,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ù)  更多評(píng)論   

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

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

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

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

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

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

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

            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ù)  更多評(píng)論   

            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編譯的問(wèn)題  回復(fù)  更多評(píng)論   

            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)了下面的問(wè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ù)  更多評(píng)論   

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

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

            2009-05-03 12:48 by 創(chuàng)意產(chǎn)品
            學(xué)習(xí)了,謝謝
            中文字幕热久久久久久久| 亚洲午夜福利精品久久| 麻豆国内精品久久久久久| 国产成年无码久久久久毛片| 国产精品久久久久久久久软件 | 亚洲综合久久综合激情久久| 日日噜噜夜夜狠狠久久丁香五月| 久久精品无码免费不卡| 国产福利电影一区二区三区久久久久成人精品综合 | 亚洲国产精品无码久久久蜜芽 | 精品99久久aaa一级毛片| 亚洲成色999久久网站| 狠狠色丁香久久婷婷综合_中| 91视频国产91久久久| 成人免费网站久久久| 亚洲午夜无码久久久久小说| 国产精品欧美久久久天天影视| 久久久久久国产精品免费免费| 久久夜色精品国产噜噜麻豆| 欧美一级久久久久久久大| 天天影视色香欲综合久久| 久久天堂电影网| 久久综合久久鬼色| 久久精品国产一区二区三区日韩| 国产精品99久久精品爆乳| 久久久精品人妻一区二区三区四| 久久久久亚洲AV成人片| 久久久久久免费视频| 久久99精品久久只有精品| 久久天天躁夜夜躁狠狠躁2022| 久久香蕉超碰97国产精品| 国产精品亚洲综合久久| 色欲综合久久躁天天躁| 久久久精品国产Sm最大网站| 94久久国产乱子伦精品免费| 国产精品99精品久久免费| 日韩乱码人妻无码中文字幕久久| 伊人久久精品无码二区麻豆| 狠狠色丁香久久婷婷综合_中 | 久久99热这里只频精品6| 99久久做夜夜爱天天做精品|