• <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類常用函數(shù)

            string類的構(gòu)造函數(shù):
            string(const char *s); ? //用c字符串s初始化
            string(int n,char c); ? //用n個字符c初始化
            此外,string類還支持默認構(gòu)造函數(shù)和復制構(gòu)造函數(shù),如string s1;string s2="hello";都是正確的寫法。當構(gòu)造的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函數(shù)提供范圍檢查,當越界時會拋出out_of_range異常,下標運算符[]不提供檢查訪問。
            const char *data()const;//返回一個非null終止的c字符數(shù)組
            const char *c_str()const;//返回一個以null終止的c字符串


            string的特性描述:
            int capacity()const; ? //返回當前容量(即string中不必增加內(nèi)存即可存放的元素個數(shù))
            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<<用于輸出操作。
            函數(shù)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連接到當前字符串的結(jié)尾
            string &append(const char *s); ? ? ? ? //把c類型字符串s連接到當前字符串結(jié)尾
            string &append(const char *s,int n);//把c類型字符串s的前n個字符連接到當前字符串結(jié)尾
            string &append(const string &s); ? //同operator+=()
            string &append(const string &s,int pos,int n);//把字符串s中從pos開始的n個字符連接到當前字符串的結(jié)尾
            string &append(int n,char c); ? ? //在當前字符串結(jié)尾添加n個字符c
            string &append(const_iterator first,const_iterator last);//把迭代器first和last之間的部分連接到當前字符串的結(jié)尾


            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函數(shù)在>時返回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久久精品免费看国产一区二区三区 | 激情五月综合综合久久69| 久久中文字幕人妻熟av女| 久久久艹| 亚洲精品99久久久久中文字幕| 精品99久久aaa一级毛片| 成人精品一区二区久久久| 精品国产福利久久久| 国内精品久久九九国产精品| 国内精品九九久久久精品| 久久精品国产69国产精品亚洲| 久久99中文字幕久久| 伊人久久综合热线大杳蕉下载| 久久99国产精品一区二区| 91精品久久久久久无码| 欧美一级久久久久久久大片| 久久久久亚洲AV综合波多野结衣| 久久影院亚洲一区| 亚洲αv久久久噜噜噜噜噜| 久久精品人成免费| 国产精品青草久久久久福利99 | 伊人久久综合无码成人网| 无码国产69精品久久久久网站| 久久丫精品国产亚洲av| 国产精品久久久久久搜索| 国产精品免费看久久久香蕉| 一本色综合久久| 国内精品久久久久伊人av| 久久久久人妻一区精品| 亚洲AV无码久久精品蜜桃| 精品久久久久久综合日本| 久久人人爽人人爽AV片| 久久久久亚洲av无码专区 | 久久亚洲AV成人无码电影| 品成人欧美大片久久国产欧美...| 久久天天躁狠狠躁夜夜2020| 人妻少妇久久中文字幕一区二区 | 久久综合综合久久狠狠狠97色88| 日本久久久久久久久久| 国产精品久久久久久搜索| 久久国产亚洲精品|