• <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>
            數(shù)據(jù)加載中……

            【轉(zhuǎn)】關(guān)于C++虛函數(shù)

                 摘要: C++ 虛函數(shù)   閱讀全文

            posted @ 2010-06-17 11:52 Stone xin 閱讀(248) | 評(píng)論 (0)編輯 收藏

            【wxWidgets】從外部調(diào)用wxDLL

                 摘要: wxWidgets dll外部調(diào)用  閱讀全文

            posted @ 2010-06-07 11:11 Stone xin 閱讀(280) | 評(píng)論 (0)編輯 收藏

            進(jìn)一步分析vector的刪除

            項(xiàng)目開(kāi)發(fā)中用到了vector,自己定義了一個(gè)數(shù)據(jù)類型 myType,用vector來(lái)保存。
            在刪除的時(shí)候出現(xiàn)了個(gè)問(wèn)題。


            #include <vector>
            #include <algorithm>
            class MyClass
            {
            public:
                MyClass(int v){ m_value=v;}
                virtual ~MyClass(){}
                MyClass  operator=(const MyClass& otherData); 
                bool  operator==(const MyClass& otherData); 

                int m_value;
            }

            MyClass::operator =(const MyClass &otherData)
            {
                return *this;
            }

            bool MyClass::operator ==(const MyClass &otherData)
            {
                if (otherData.m_value==this->m_value)
                {
                    return true;
                }else
                {
                    return false;
                }
            }


            int main()
            {
                std::vector<MyClass> myVector;
                MyClass v1(1);
                MyClass v2(2);
                MyClass v3(3);
                myVector.push_back(v1);
                myVector.push_back(v2);
                myVector.push_back(v3);

                for( std::vector<MyClass>::iterator result=myVector.begin();
                    result!=myVector.end();
                    ++result) 
                {
                    cout << "Element " << result->m_value << endl;
                }

                MyClass v(2);
                std::vector<MyClass>::iterator it = std::find(myVector.begin(),myVector.end(),v);
                if (it!=myVector.end())
                {
                    myVector.erase(it);
                }
                for( std::vector<MyClass>::iterator result=myVector.begin();
                    result!=myVector.end();
                    ++result) 
                {
                    cout << "After erase MyClass v(2), Element left " << result->m_value << endl;
                }
                return 0;
            }




            猜猜看輸出結(jié)果會(huì)是什么?
            如果你想當(dāng)然的認(rèn)為是
            Element 1
            Element 2
            Element 3
            After erase MyClass v(2), Element left 1
            After erase MyClass v(2), Element left 3
            那就錯(cuò)了!
            Element 1
            Element 2
            Element 3
            After erase MyClass v(2), Element left 1
            After erase MyClass v(2), Element left 2
            這個(gè)才是結(jié)果。
            這當(dāng)中因?yàn)橹剌d了賦值運(yùn)算符,vector在刪除一個(gè)元素的時(shí)候,我猜測(cè)是把后一個(gè)元素的值,賦給了刪除的。如果賦值操作符中沒(méi)有處理得當(dāng),那么就會(huì)出現(xiàn)令人摸不著頭腦的問(wèn)題。

            posted @ 2009-12-10 17:41 Stone xin 閱讀(1483) | 評(píng)論 (0)編輯 收藏

            [wxWidgets]Embedding PNG images into executables(將png嵌入到程序中)

            首先需要用工具將png圖片轉(zhuǎn)成.cpp或者.h文件
            工具:bin2c
            源代碼:

            // bin2c.c
            //
            // convert a binary file into a C source vector
            //
            // THE "BEER-WARE LICENSE" (Revision 3.1415):
            // sandro AT sigala DOT it wrote this file. As long as you retain this notice you can do
            // whatever you want with this stuff.  If we meet some day, and you think this stuff is
            // worth it, you can buy me a beer in return.  Sandro Sigala
            //
            // syntax:  bin2c [-c] [-z] <input_file> <output_file>
            //
            //          -c    add the "const" keyword to definition
            //          -z    terminate the array with a zero (useful for embedded C strings)
            //
            // examples:
            //     bin2c -c myimage.png myimage_png.cpp
            //     bin2c -z sometext.txt sometext_txt.cpp

            #include 
            <ctype.h>
            #include 
            <stdio.h>
            #include 
            <stdlib.h>
            #include 
            <string.h>

            #ifndef PATH_MAX
            #define PATH_MAX 1024
            #endif

            int useconst = 0;
            int zeroterminated = 0;

            int myfgetc(FILE *f)
            {
                
            int c = fgetc(f);
                
            if (c == EOF && zeroterminated)
                
            {
                    zeroterminated 
            = 0;
                    
            return 0;
                }

                
            return c;
            }


            void process(const char *ifname, const char *ofname)
            {
                FILE 
            *ifile, *ofile;
                errno_t err 
            = fopen_s(&ifile,ifname,"rb");
                
            if (ifile == NULL)
                
            {
                    fprintf(stderr, 
            "cannot open %s for reading\n", ifname);
                    exit(
            1);
                }

                fopen_s(
            &ofile,ofname, "wb");
                
            if (ofile == NULL)
                
            {
                    fprintf(stderr, 
            "cannot open %s for writing\n", ofname);
                    exit(
            1);
                }

                
            char buf[PATH_MAX], *p;
                
            const char *cp;
                
            if ((cp = strrchr(ifname, '/')) != NULL)
                
            {
                    
            ++cp;
                }
             else {
                    
            if ((cp = strrchr(ifname, '\\')) != NULL)
                        
            ++cp;
                    
            else
                        cp 
            = ifname;
                }

                strcpy_s(buf, cp);
                
            for (p = buf; *!= '\0'++p)
                
            {
                    
            if (!isalnum(*p))
                        
            *= '_';
                }

                fprintf(ofile, 
            "static %sunsigned char %s[] = {\n", useconst ? "const " : "", buf);
                
            int c, col = 1;
                
            while ((c = myfgetc(ifile)) != EOF)
                
            {
                    
            if (col >= 78 - 6)
                    
            {
                        fputc(
            '\n', ofile);
                        col 
            = 1;
                    }

                    fprintf(ofile, 
            "0x%.2x, ", c);
                    col 
            += 6;
                }

                fprintf(ofile, 
            "\n};\n");

                fclose(ifile);
                fclose(ofile);
            }


            void usage(void)
            {
                fprintf(stderr, 
            "usage: bin2c [-cz] <input_file> <output_file>\n");
                exit(
            1);
            }


            int main(int argc, char **argv)
            {
                
            while (argc > 3)
                
            {
                    
            if (!strcmp(argv[1], "-c"))
                    
            {
                        useconst 
            = 1;
                        
            --argc;
                        
            ++argv;
                    }
             else if (!strcmp(argv[1], "-z"))
                    
            {
                        zeroterminated 
            = 1;
                        
            --argc;
                        
            ++argv;
                    }
             else {
                        usage();
                    }

                }

                
            if (argc != 3)
                
            {
                    usage();
                }

                process(argv[
            1], argv[2]);
                
            return 0;
            }

            在官方論壇中的做了些修改。去掉了一些警告信息。

            2、在你的程序中包含轉(zhuǎn)換好的cpp或者h(yuǎn)
             #include <myimage_png.cpp>

            wxMemoryInputStream istream(myimage_png, sizeof myimage_png);
            wxImage myimage_img(istream, wxBITMAP_TYPE_PNG);

            或者可以定義個(gè)宏

            #define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name ## _png, sizeof(name ## _png))
            inline wxBitmap _wxGetBitmapFromMemory(const unsigned char *data, int length) {
            wxMemoryInputStream is(data, length);
            return wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1);
            }
            
            注意:要確保png的句柄初始化了。wxImage::AddHandler(new wxPNGHandler);
            

            posted @ 2009-12-04 11:07 Stone xin 閱讀(525) | 評(píng)論 (0)編輯 收藏

            Ticpp demo程序

            將網(wǎng)上的TinyXML++的demo程序用vs2005建了個(gè)sample_ticpp工程,供大家學(xué)習(xí)參考。

            posted @ 2009-12-01 15:18 Stone xin 閱讀(303) | 評(píng)論 (0)編輯 收藏

            Doxygen使用

                 摘要: Doxygen使用  閱讀全文

            posted @ 2009-10-10 17:49 Stone xin 閱讀(258) | 評(píng)論 (0)編輯 收藏

            c++參考手冊(cè)

            經(jīng)常用到的東西,但一時(shí)總是找不到在哪里下載,所以把地址放到這里,備忘
            http://www.cppreference.com/wiki/about/faq

            最新的手冊(cè)地址是:c++手冊(cè)

            posted @ 2009-10-06 12:40 Stone xin 閱讀(675) | 評(píng)論 (0)編輯 收藏

            僅列出標(biāo)題
            共4頁(yè): 1 2 3 4 
            久久九九免费高清视频| 久久久久久久综合日本| 亚洲国产精品无码久久久不卡 | 国产精品日韩欧美久久综合| 久久精品www| 无码任你躁久久久久久老妇| 欧美精品丝袜久久久中文字幕 | 色综合久久综合中文综合网| 国产精品一区二区久久精品无码| 亚洲国产成人久久综合碰碰动漫3d | 日本三级久久网| 亚洲国产成人久久综合碰| 亚洲中文字幕无码久久2020| 精品人妻久久久久久888| 久久九九久精品国产| 精品久久久久久无码专区| 91精品婷婷国产综合久久| 偷偷做久久久久网站| 久久九九亚洲精品| 亚洲欧美伊人久久综合一区二区 | 色婷婷狠狠久久综合五月| 久久国产精品99国产精| 亚洲日本久久久午夜精品| 91精品国产高清91久久久久久| 亚洲国产日韩欧美久久| 亚洲狠狠婷婷综合久久蜜芽| 精品久久久久久无码专区| 亚洲人成无码www久久久| 久久久综合九色合综国产| 精品久久久久久久无码| 人妻无码精品久久亚瑟影视| 久久婷婷色综合一区二区| 国产精久久一区二区三区| 99久久国语露脸精品国产| 久久久精品国产sm调教网站| 久久综合给合久久国产免费| 久久天天躁夜夜躁狠狠躁2022| 欧美大战日韩91综合一区婷婷久久青草| 久久精品成人国产午夜| 青青草原综合久久| 热久久这里只有精品|