亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mystring.cpp

?? 一本語言類編程書籍
?? CPP
字號:
// Exercise 14.2 MyString.cpp
// Definitions for member of the MyString class

#include "MyString.h"
#include <cstdlib>
#include <iostream>
using std::cout;
using std::endl;

namespace mySpace {

  // Default constructor
  MyString::MyString() {
    strLength = 0;               // Length excludes terminating null - this is empty string
    pStr = new char[1];          // Allocate space for string in the free store
    *pStr = '\0';                // Store terminating null
  }

  // Construct from a C-style string
  MyString::MyString(const char* pString) {
    strLength = strlen(pString);  // strlen() returns length excluding terinating null
    pStr = new char[strLength+1]; // Space must allow for null, hence strLength+1
    strcpy(pStr, pString);        // Copy argument string to data member
  }

  // Construct from repeated character
  MyString::MyString(char ch, int n) {
    strLength = n;
    pStr = new char[strLength+1];
    for(unsigned int i = 0 ; i<strLength ; *(pStr+i++) = ch) // 3rd expression stores ch then increments i
      ;                                             // No loop statement...
    *(pStr+strLength) = '\0';     // Store terminating null
  }

  // Construct string representation of integer
  MyString::MyString(int number) {
    char buffer[20];                    // Buffer to store string representation
    int temp = number;
    if(number<0)                        // If it is negative, 
      number = -number;                 // reverse the sign

    // Convert digits to characters in reverse order 
    int len = 0;
    do {
      buffer[len++] = static_cast<char>('0' + number%10);
      number /= 10;
    }while(number>0);
    if(temp<0)                          // If it was negative
      buffer[len++] = '-';              // Append a minus sign
    buffer[len] = '\0';                 // Apeend terminal \0

    strLength = len;                    // Store length of string

    pStr = new char[strLength+1];       // Allocate space
    std::strcpy(pStr, buffer);          // Copy string to data member
    // String is reversed so reverse it in place
    char ch = 0;
    for(int i = 0, j = len-1 ; i<j ; i++, j--) {
      ch = pStr[i];
      pStr[i] = pStr[j];
      pStr[j] = ch;
    }
  }

  // Copy constructor
  // Needs to allocate space for a copy of the string, then copy it
  MyString::MyString(const MyString& rString) {
    strLength = rString.strLength; // Store the length
    pStr = new char[strLength+1];  // Allocate the required space
    strcpy(pStr, rString.pStr);    // Copy the string
  }

  // Destructor
  // releases free store memory allocated to store string
  MyString::~MyString() {
    delete[] pStr;                 // Must use array form of delete here
  }

  // Find the position of a character
  // Compares succesive characters in the satring with the argument
  int MyString::find(char ch) const   {
    for(unsigned int i = 0 ; i<strLength ; i++)
      if(ch == *(pStr+i))           // If we find the character,
        return i;                   // return its position,
    return -1;                      // otherwise return -1
  }

  // Find the position of a string
  // Searches for the first character of the substring
  // and looks for the remaining characters if it is found
  int MyString::find(const char* pString) const {
    bool found = false;             // Sub-string found indicator

    // Search for the sub-string. We only need to look for
    // the first character up to the position where there is
    // enough room left for the sub-string to appear.
    for(unsigned int i = 0 ; i<strLength-strlen(pString)+1 ; i++)
      if(*(pStr+i) == *pString) {                 // If we find the first character
        found = true;
        for(unsigned int j = 1 ; j<strlen(pString) ; j++)  // look for the rest of the sub-string
          if(*(pStr+i+j) != *(pString+j)) {       // If any character doesn't match,
            found = false;                        // we didn't find it 
            break;                                // so go to next iteration in outer loop
          }
          if(found)                               // If we found it,
            return i;                             // Return the position,
      }
      return -1;                                  // otherwise return -1
  }

  // Find the occurrence of a MyString as a sub-string
  int MyString::find(const MyString& rString) const {
    return find(rString.pStr);                    // Just use the previous function to do it
  }

  // Display the string
  void MyString::show() const {
    if(strLength)
      cout << endl << pStr;
    else
      cout << endl << "String is empty.";
  }

  // Overloaded assignment operator
  MyString& MyString::operator=(const MyString& rhs) {
    if(this == &rhs)                      // Is lhs same object as rhs?
      return *this;                       // Yes, so just return it.

    // Objects are different so assign rhs to *this
    delete[] pStr;                        // Release memory for current string for *this object
    pStr = new char[rhs.strLength+1];     // Allocate space for string to be copied
    std::strcpy(pStr,rhs.pStr);           // Copy rhs string to lhs
    strLength = rhs.strLength;            // Set the length
    return *this;
  }

  // String concatenation
  // Operator must return a new object which is created as a local object 
  // A copy of the local object will be returned
  MyString MyString::operator+(const MyString& rhs) const {
    return MyString(*this) += rhs;
  }

  // Append MyString string
  // Operator returns a reference to the lhs
  // Uses the += operator for C-style strings to append the rhs string
  MyString& MyString::operator+=(const MyString& rhs) {
    return *this += rhs.pStr;  
  }

  // Append C-style string
  MyString& MyString::operator+=(const char* rhs) {
    char* pNewStr = new char[strLength+strlen(rhs)+1];   // Space for combined string
    std::strcpy(pNewStr,pStr);                           // Copy lhs string to new string
    std::strcpy(pNewStr+strLength,rhs);                  // Append rhs string to new string
    strLength += std::strlen(rhs);                       // Update length
    delete[] pStr;                                       // Release lhs string memory
    pStr = pNewStr;                                      // lhs string is new string
    return *this;                                        // Return lhs
  }

}   // End of namespace mySpace;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产不卡在线一区| 91精品国产欧美一区二区成人 | 亚洲天堂久久久久久久| 午夜电影久久久| 成人性视频网站| 欧美一级欧美三级在线观看 | 一区二区三区四区视频精品免费| 青青草原综合久久大伊人精品 | 99久久精品99国产精品| 欧美三级韩国三级日本三斤| 欧美不卡123| 一区二区三区久久| 国产sm精品调教视频网站| 91精品国产综合久久香蕉的特点 | 国产成人在线观看| 欧美一区二区视频观看视频| 亚洲色图在线播放| 国v精品久久久网| 亚洲精品在线免费观看视频| 视频一区二区国产| 欧美性色黄大片| 中文文精品字幕一区二区| 久久国产生活片100| 在线不卡中文字幕播放| 亚洲午夜视频在线| 欧美综合色免费| 亚洲美女偷拍久久| 91看片淫黄大片一级| 中文字幕精品—区二区四季| 国产一区二区三区久久久| 日韩欧美三级在线| 免费欧美高清视频| 日韩欧美国产高清| 久久精品久久99精品久久| 欧美一区二区网站| 美女视频一区在线观看| 欧美电视剧在线看免费| 蜜臀av性久久久久蜜臀av麻豆| 制服丝袜日韩国产| 麻豆国产欧美一区二区三区| 欧美成人三级在线| 国产一区 二区| 国产日韩亚洲欧美综合| www.日韩在线| 一区二区三区在线观看国产 | 亚洲综合视频在线观看| 欧美色精品在线视频| 天天综合网 天天综合色| 91麻豆精品91久久久久同性| 精品制服美女久久| 国产三级欧美三级| www.成人网.com| 一区二区三区精品视频在线| 欧美高清视频www夜色资源网| 五月激情六月综合| 欧美电影免费观看高清完整版在线观看 | 亚洲精品成人天堂一二三| 欧美在线不卡视频| 青青草原综合久久大伊人精品 | 欧美中文字幕一区| 日韩不卡一二三区| 久久久高清一区二区三区| 色综合天天综合网天天狠天天| 亚洲国产视频在线| 精品国产精品网麻豆系列| www.激情成人| 日韩av成人高清| 国产欧美日韩三区| 精品1区2区3区| 国产福利一区二区三区视频在线 | 91网站最新网址| 日日夜夜一区二区| 国产精品毛片久久久久久| 欧美日韩你懂得| 粉嫩嫩av羞羞动漫久久久 | 欧美区一区二区三区| 国内偷窥港台综合视频在线播放| 国产精品国产三级国产| 91精品国产一区二区| heyzo一本久久综合| 日韩国产在线观看一区| 自拍偷拍亚洲综合| 久久久久国产精品麻豆| 欧美色区777第一页| 成人精品高清在线| 美脚の诱脚舐め脚责91| 一区二区国产视频| 久久久综合激的五月天| 欧美日本韩国一区| 97se狠狠狠综合亚洲狠狠| 日本不卡123| 一级中文字幕一区二区| 中文一区二区在线观看| 日韩免费一区二区三区在线播放| 日本乱人伦aⅴ精品| 国产大片一区二区| 久久99精品一区二区三区三区| 亚洲小说欧美激情另类| 中文字幕亚洲一区二区av在线| 久久久久久久久久久久久久久99 | 亚洲成人在线免费| 亚洲欧美怡红院| 亚洲国产高清aⅴ视频| 精品国精品国产尤物美女| 91精品国产综合久久精品性色| 色欧美乱欧美15图片| 成a人片国产精品| 国产aⅴ综合色| 国产91在线|亚洲| 国产v综合v亚洲欧| 国产综合色在线视频区| 久久精品久久综合| 久久机这里只有精品| 久久国产三级精品| 国产自产视频一区二区三区| 麻豆91精品91久久久的内涵| 婷婷开心久久网| 三级不卡在线观看| 人人超碰91尤物精品国产| 日韩黄色小视频| 久久99国产精品久久99果冻传媒| 欧美aa在线视频| 九色porny丨国产精品| 免费欧美高清视频| 国产一区二区三区不卡在线观看| 精品中文字幕一区二区小辣椒 | 99精品国产一区二区三区不卡| 成人涩涩免费视频| a美女胸又www黄视频久久| 99久久久无码国产精品| 欧美在线你懂得| 欧美日韩在线播| 日韩一区二区三| 欧美精品一区二区三区在线 | 国产剧情一区二区| 丁香六月久久综合狠狠色| 成人免费视频网站在线观看| 成人av网站在线观看免费| 91久久免费观看| 欧美精品1区2区3区| 欧美成人vps| 国产精品女上位| 亚洲制服丝袜在线| 久久精品国产精品亚洲精品| 国产成人超碰人人澡人人澡| 91在线看国产| 91精品福利在线一区二区三区| 久久蜜桃av一区精品变态类天堂| 亚洲欧美一区二区在线观看| 日日夜夜精品视频天天综合网| 国产一区二区三区免费| 色天使色偷偷av一区二区| 欧美xxxxx裸体时装秀| 国产精品美女久久久久久久久 | 91精品国产乱| 欧美激情综合五月色丁香小说| 一区二区三区影院| 久久99精品国产麻豆婷婷 | 亚洲亚洲精品在线观看| 国内精品伊人久久久久av一坑| 91蜜桃婷婷狠狠久久综合9色| 欧美日本一区二区三区四区| 中文字幕乱码亚洲精品一区| 日本美女视频一区二区| 91在线免费看| 国产三级精品三级| 日日摸夜夜添夜夜添国产精品| 成人短视频下载| 欧美mv和日韩mv国产网站| 亚洲欧美日韩系列| 国产a久久麻豆| 欧美成人一区二区三区片免费| 亚洲一区在线视频| caoporm超碰国产精品| 精品99999| 日韩电影免费在线| 欧美视频三区在线播放| 亚洲视频小说图片| 国产精品911| 精品国产sm最大网站免费看| 亚洲成人久久影院| 日本丶国产丶欧美色综合| 国产欧美一区二区精品婷婷| 麻豆视频一区二区| 精品视频在线视频| 亚洲欧美日韩国产综合| av日韩在线网站| 久久久久88色偷偷免费| 久久99精品久久久久久| 欧美一级生活片| 日韩有码一区二区三区| 欧美色图片你懂的| 亚洲在线观看免费| 色综合一区二区三区| 综合网在线视频| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 一区二区三区在线视频观看| 国产成人在线视频免费播放| 日韩精品一区二区三区在线播放| 午夜精品影院在线观看|