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

            天下

            記錄修行的印記

            備忘,MyString實現

            <1>
            //a.h
            #pragma once
            class MyString
            {
            public:
                MyString(
            const char* pszText);
                MyString(
            const MyString& strText);

                MyString
            & operator=(const MyString& strText);
                MyString
            & operator=(const char* pszText);

                
            operator const char*();

                
            ~MyString();
            protected:
                
            int m_len;
                
            char* m_data;
            };

            <2>
            #include "stdafx.h"


            MyString::MyString(
            const char* pszText):m_len(0),m_data(NULL)
            {
                m_len 
            = strlen(pszText);
                m_data 
            = new char[m_len+1];
                strcpy(m_data,pszText);
            }

            MyString::MyString(
            const MyString& strText):m_len(0),m_data(NULL)
            {
                
            *this = strText;
            }

            MyString::
            ~MyString()
            {
                
            if (m_data!=NULL)
                {
                    delete[] m_data;
                    m_data 
            = NULL;
                }
                m_len 
            = 0;
            }


            MyString
            & MyString::operator=(const MyString& strText)
            {
                
            if (this==&strText)
                {
                    
            return *this;
                }
                m_len 
            = strText.m_len;
                
            if (m_data!=NULL)
                {
                    delete[] m_data;
                }
                m_data 
            = new char[m_len+1];
                strcpy(m_data,strText.m_data);
                return *this;
            }

            MyString
            & MyString::operator=(const char* pszText)
            {
                
            if (m_data!=NULL)
                {
                    delete[] m_data;
                }
                m_len  
            = strlen(pszText);
                m_data 
            = new char[m_len+1];
                strcpy(m_data,pszText);
                
            return *this;
            }

            MyString::
            operator const char*()
            {
                
            return  const_cast<const char*>(m_data); 
            }

            <3>
            #include "stdafx.h"
            int main() 
            {
                MyString str(
            "abc");

                MyString str1(str);
                str1 
            = str1;

                printf(
            "%s \r\n",(const char*)str);
                system(
            "pause");
                
            return 0;
            }


            posted on 2012-09-11 10:43 天下 閱讀(390) 評論(0)  編輯 收藏 引用 所屬分類: C/C++

            <2013年3月>
            242526272812
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            導航

            統計

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評論

            精品国产乱码久久久久久1区2区 | 少妇内射兰兰久久| 久久97久久97精品免视看| 狠狠色丁香久久综合五月| 久久99精品久久久久久| 国产成人99久久亚洲综合精品| 久久久噜噜噜久久中文字幕色伊伊| 午夜视频久久久久一区| 久久亚洲精品国产精品| 久久婷婷五月综合色99啪ak| 久久五月精品中文字幕| 一本色道久久88精品综合| 精品久久久久中文字| 91麻豆国产精品91久久久| 99热精品久久只有精品| 亚洲国产综合久久天堂| 久久夜色精品国产亚洲| 久久久久亚洲av无码专区喷水 | AV无码久久久久不卡蜜桃| 久久福利青草精品资源站| 中文字幕无码av激情不卡久久| 国产午夜精品久久久久免费视| 伊人久久一区二区三区无码| 99久久精品免费看国产一区二区三区 | 久久亚洲精品视频| 久久久亚洲欧洲日产国码aⅴ| 久久精品国产国产精品四凭| 97久久超碰国产精品旧版| 久久精品黄AA片一区二区三区| 久久久久综合中文字幕 | 久久精品水蜜桃av综合天堂| 色偷偷91久久综合噜噜噜噜| 91久久精品国产91性色也| 国产精品久久亚洲不卡动漫| 三上悠亚久久精品| 亚洲国产欧美国产综合久久| 亚洲欧美成人久久综合中文网| 欧美国产精品久久高清| 久久综合久久伊人| 久久婷婷五月综合成人D啪| 亚洲精品乱码久久久久久自慰 |