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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mystring.cpp

?? 一本語言類編程書籍
?? CPP
字號:
// Exercise 14.1 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;  
  }

}   // End of namespace mySpace;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91婷婷韩国欧美一区二区| 国内外成人在线| 中文字幕日本乱码精品影院| 2023国产精品视频| 日韩欧美在线综合网| 欧美一级欧美一级在线播放| 欧美美女视频在线观看| 在线观看视频一区| 欧美日韩一二区| 欧美美女bb生活片| 欧美一级在线视频| 欧美不卡123| 久久只精品国产| 欧美激情在线看| 国产精品高清亚洲| 亚洲精品成人悠悠色影视| 亚洲色图在线视频| 一区二区三区欧美久久| 婷婷激情综合网| 久久精品国产久精国产爱| 国产激情一区二区三区| 成人精品免费网站| 在线精品视频一区二区| 欧美日韩mp4| 久久久久久夜精品精品免费| 综合久久一区二区三区| 性欧美疯狂xxxxbbbb| 激情综合色综合久久| 国产99精品在线观看| 91蝌蚪国产九色| 欧美一区二区三区精品| 久久久久久毛片| 一区二区三区色| 日韩福利视频导航| 成人av网在线| 欧美日韩国产综合视频在线观看| 欧美成人bangbros| 国产精品久久综合| 日韩二区在线观看| 成人激情综合网站| 91精品国产福利| 国产精品日日摸夜夜摸av| 亚洲成va人在线观看| 国产一区二区视频在线播放| 91极品视觉盛宴| 久久久综合网站| 亚洲超碰97人人做人人爱| 国产精品一区二区在线播放 | 亚洲综合在线电影| 日本不卡在线视频| 91性感美女视频| 久久综合成人精品亚洲另类欧美| 一区二区三区精品| 国产成人在线免费| 日韩视频在线你懂得| 亚洲激情综合网| 国产露脸91国语对白| 欧美体内she精高潮| 综合欧美一区二区三区| 丁香亚洲综合激情啪啪综合| 欧美大肚乱孕交hd孕妇| 午夜精品久久一牛影视| 91丨porny丨户外露出| 国产欧美精品一区aⅴ影院| 青青草视频一区| 欧美日本视频在线| 亚洲福利电影网| 在线观看成人小视频| 亚洲日本va午夜在线影院| 国产宾馆实践打屁股91| 久久一区二区三区四区| 看片的网站亚洲| 精品少妇一区二区三区日产乱码| 午夜久久久久久久久 | 性久久久久久久| 色婷婷av一区二区三区软件 | 国内精品不卡在线| 欧美亚洲国产bt| 久久久欧美精品sm网站| 国产精品一线二线三线精华| 欧美探花视频资源| 亚洲三级电影全部在线观看高清| 黑人巨大精品欧美黑白配亚洲| 欧洲一区在线电影| 国产精品福利av| 成人午夜电影久久影院| 国产日韩高清在线| 国产精品一区二区在线观看网站| 日韩一区二区三区电影在线观看 | 国产一区二区三区免费观看| 欧美老人xxxx18| 亚洲免费视频中文字幕| 欧美性猛片aaaaaaa做受| 国产精品久久久久久一区二区三区| 久久66热re国产| 欧美成人r级一区二区三区| 蜜芽一区二区三区| 欧美一区二区久久| 青青草97国产精品免费观看| 欧美日韩一区二区在线观看 | 欧美综合久久久| 一区二区三区中文在线| 欧美性色aⅴ视频一区日韩精品| 一区二区三区中文字幕精品精品 | 国产精品一区二区91| 久久精品一区四区| 蜜桃av噜噜一区二区三区小说| 久久久久久久久久电影| 高清beeg欧美| 亚洲欧洲成人自拍| 欧美日韩中文字幕一区| 日韩电影在线免费看| 欧美不卡一区二区| 成人午夜av影视| 亚洲男人天堂av| 精品精品欲导航| 国产成人99久久亚洲综合精品| 久久精品一区二区三区四区| 成人av手机在线观看| 一区二区三区在线免费观看| 欧美日韩一级片网站| 精品综合久久久久久8888| 精品久久久久久久久久久久久久久 | 欧美日韩精品欧美日韩精品 | 2014亚洲片线观看视频免费| 粗大黑人巨茎大战欧美成人| 中文字幕中文字幕中文字幕亚洲无线| 成人污视频在线观看| 亚洲精品成人a在线观看| 日韩视频永久免费| 99久久精品国产一区二区三区 | 亚洲精品国产无天堂网2021| 欧美日韩另类一区| 国产精品一区二区在线播放| 亚洲欧洲av色图| 91久久香蕉国产日韩欧美9色| 七七婷婷婷婷精品国产| 国产精品久久久久久久久动漫| 欧美午夜一区二区三区免费大片| 美女www一区二区| 亚洲免费观看高清在线观看| 日韩三级av在线播放| 91国内精品野花午夜精品| 久久精品国产一区二区三区免费看| 中文字幕av不卡| 日韩午夜电影在线观看| 欧美在线一二三| 国产成人av电影在线| 日本不卡不码高清免费观看| 亚洲精品欧美激情| 国产喂奶挤奶一区二区三区| 欧美日韩国产综合一区二区| www.亚洲精品| 国产福利精品导航| 欧美aaaaa成人免费观看视频| 中文字幕一区日韩精品欧美| 在线播放中文一区| 色偷偷久久一区二区三区| 国产福利视频一区二区三区| 蜜桃视频一区二区| 亚洲成精国产精品女| 亚洲精品免费在线观看| 国产精品久久久久四虎| 国产区在线观看成人精品| 国产日韩欧美一区二区三区乱码| 日韩欧美国产电影| 日韩视频在线永久播放| 欧美三级日韩三级国产三级| 91在线精品一区二区三区| 国产很黄免费观看久久| 久久66热re国产| 精品一区二区免费| 国产91在线看| 高清视频一区二区| 成人爽a毛片一区二区免费| 国产高清在线精品| 国产精品一卡二| 国产激情视频一区二区在线观看| 国产伦精品一区二区三区在线观看| 国产一区二区精品在线观看| 精品亚洲成av人在线观看| 捆绑调教一区二区三区| 国产真实乱子伦精品视频| 国产在线国偷精品免费看| 国产真实乱偷精品视频免| 国产精品亚洲综合一区在线观看| 开心九九激情九九欧美日韩精美视频电影| 午夜影院久久久| 久久er精品视频| 国产精品88888| 99久久国产综合精品女不卡| 91日韩一区二区三区| 欧洲人成人精品| 欧美日韩亚州综合| 国产欧美综合色| 一区二区三区在线免费播放| 日韩精品一级二级| 国内精品第一页| 色综合一区二区| 欧美一区二区三区人|