字串 字串類的實現(資料結構基礎 第4周)

2021-07-14 10:49:53 字數 505 閱讀 6593

這裡只是簡單實現了字串的建構函式和賦值運算,其他待補充。

原始碼

#pragma 

#include

class

string

string(char* s)

~string()

//此處返回值必須為引用

string& operator = (string& s)

strcpy(str, s.c_str());

return *this; //返回本例項,作為string類的乙個例項

}int size()

char* c_str()

};

#include

#include "string.h"

using

namespace

std;

int main()

標準字串函式及 字串類 資料結構

懶得再開乙個隨筆寫心事,直接就在這篇裡說了算了。昨天晚上經歷了六個小時的納新面試,掐指頭算時我都被震驚到了。簡單總結一下 原來真不是只有本事 靠譜就夠了。剛剛看見的那條動態說的沒錯,有一顆好心不如張一張好嘴 有本事不會推銷自己,那是茶壺煮餃子,頂多算靠譜但不能委以重任,光說不練假把式,最多做個活躍氣...

資料結構 字串

1 字串 include string.h include stdio.h include stdlib.h include math.h include time.h define ok 1 define error 0 define true 1 define false 0 define ma...

資料結構 字串

字串是由0個或多個字元構成的序列,可記為s a1a2a3 an 其中ai可以是字母,也可是數字或者其他字元,零個字元的串稱為空串。而字串的順序結構就是用簡單的char型別陣列來儲存沒什麼好說的,下面介紹一下bf演算法與kmp演算法 bf演算法就是比較平常的雙重迴圈,如果匹配成功打斷迴圈,否則子串的比...