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

            牽著老婆滿街逛

            嚴以律己,寬以待人. 三思而后行.
            GMail/GTalk: yanglinbo#google.com;
            MSN/Email: tx7do#yahoo.com.cn;
            QQ: 3 0 3 3 9 6 9 2 0 .

            C++string類常用函數

            string類的構造函數:
            string(const char *s); ? //用c字符串s初始化
            string(int n,char c); ? //用n個字符c初始化
            此外,string類還支持默認構造函數和復制構造函數,如string s1;string s2="hello";都是正確的寫法。當構造的string太長而無法表達時會拋出length_error異常


            string類的字符操作:
            const char &operator[](int n)const;
            const char &at(int n)const;
            char &operator[](int n);
            char &at(int n);
            operator[]和at()均返回當前字符串中第n個字符的位置,但at函數提供范圍檢查,當越界時會拋出out_of_range異常,下標運算符[]不提供檢查訪問。
            const char *data()const;//返回一個非null終止的c字符數組
            const char *c_str()const;//返回一個以null終止的c字符串


            string的特性描述:
            int capacity()const; ? //返回當前容量(即string中不必增加內存即可存放的元素個數)
            int max_size()const; ? //返回string對象中可存放的最大字符串的長度
            int size()const; ? ? //返回當前字符串的大小
            int length()const; ? ? //返回當前字符串的長度
            bool empty()const; ? ? //當前字符串是否為空
            void resize(int len,char c);//把字符串當前大小置為len,并用字符c填充不足的部分


            string類的輸入輸出操作:
            string類重載運算符operator>>用于輸入,同樣重載運算符operator<<用于輸出操作。
            函數getline(istream &in,string &s);用于從輸入流in中讀取字符串到s中,以換行符'\n'分開。


            string的賦值:
            string &operator=(const string &s);//把字符串s賦給當前字符串
            string &assign(const char *s);//用c類型字符串s賦值
            string &assign(const char *s,int n);//用c字符串s開始的n個字符賦值
            string &assign(const string &s);//把字符串s賦給當前字符串
            string &assign(int n,char c);//用n個字符c賦值給當前字符串
            string &assign(const string &s,int start,int n);//把字符串s中從start開始的n個字符賦給當前字符串
            string &assign(const_iterator first,const_itertor last);//把first和last迭代器之間的部分賦給字符串


            string的連接:
            string &operator+=(const string &s);//把字符串s連接到當前字符串的結尾
            string &append(const char *s); ? ? ? ? //把c類型字符串s連接到當前字符串結尾
            string &append(const char *s,int n);//把c類型字符串s的前n個字符連接到當前字符串結尾
            string &append(const string &s); ? //同operator+=()
            string &append(const string &s,int pos,int n);//把字符串s中從pos開始的n個字符連接到當前字符串的結尾
            string &append(int n,char c); ? ? //在當前字符串結尾添加n個字符c
            string &append(const_iterator first,const_iterator last);//把迭代器first和last之間的部分連接到當前字符串的結尾


            string的比較:
            bool operator==(const string &s1,const string &s2)const;//比較兩個字符串是否相等
            運算符">","<",">=","<=","!="均被重載用于字符串的比較;
            int compare(const string &s) const;//比較當前字符串和s的大小
            int compare(int pos, int n,const string &s)const;//比較當前字符串從pos開始的n個字符組成的字符串與s的大小
            int compare(int pos, int n,const string &s,int pos2,int n2)const;//比較當前字符串從pos開始的n個字符組成的字符串與s中pos2開始的n2個字符組成的字符串的大小
            int compare(const char *s) const;
            int compare(int pos, int n,const char *s) const;
            int compare(int pos, int n,const char *s, int pos2) const;
            compare函數在>時返回1,<時返回-1,==時返回0


            string的字串:
            string substr(int pos = 0,int n = npos) const;//返回pos開始的n個字符組成的字符串


            string的交換:
            void swap(string &s2); ? //交換當前字符串與s2的值

            posted on 2006-07-25 21:02 楊粼波 閱讀(273) 評論(0)  編輯 收藏 引用 所屬分類: 文章收藏

            99久久精品免费观看国产| 久久久黄片| 中文字幕乱码人妻无码久久| 久久无码AV中文出轨人妻| 日产精品久久久久久久性色| 99久久中文字幕| 婷婷久久综合九色综合九七| 亚洲精品无码久久久久sm| 99久久精品国产一区二区| 欧美激情一区二区久久久| 国产精品99精品久久免费| 欧美性大战久久久久久| 久久91精品国产91久久小草| 一本色道久久88综合日韩精品| 精品久久久久久中文字幕人妻最新 | 久久久精品人妻一区二区三区四 | 久久夜色精品国产亚洲| 国产精品久久久久久久久久影院| 久久久中文字幕| 99蜜桃臀久久久欧美精品网站| 国产69精品久久久久99| 久久久av波多野一区二区| 国产精品乱码久久久久久软件| 伊人久久免费视频| 精品无码久久久久久尤物| 7777精品久久久大香线蕉| 欧美久久一区二区三区| 国产免费久久精品丫丫| 色综合久久天天综合| 国产精品岛国久久久久| 久久久精品国产sm调教网站 | 欧美性大战久久久久久| 久久国产综合精品五月天| 国产欧美久久久精品| 国产亚洲综合久久系列| 久久香蕉超碰97国产精品| 久久亚洲精精品中文字幕| 精品国产乱码久久久久久郑州公司| 久久精品无码一区二区无码| 久久久久亚洲精品天堂| 97久久精品午夜一区二区|