📄 str.h
字号:
#include<iostream.h>
class String
{
friend bool operator==(const String &first, const String &second);
friend bool operator>(const String &first, const String &second);
friend bool operator<(const String &first, const String &second);
friend bool operator>=(const String &first, const String &second);
friend bool operator<=(const String &first, const String &second);
friend bool operator!=(const String &first, const String &second);
friend ostream &operator<<(ostream&,String &s);
friend istream &operator>>(istream&,String &s);
friend int strlen(String &s);
friend void strcat(String &add_to, const String &add_on);
friend void strcpy(String ©, const String &original);
friend void strncpy(String ©, const String &original, int n);
friend void KMP_Fail(const String &pat,int *f); // KMP算法中计算模式串pat的失效函数
friend int KMP_Find(const String &tag,const String &pat); // 用KMP算法实现Find
friend int strstr(const String &text, const String &target);
friend void write(ostream& out, String &s);
public: // methods of the string ADT
String( ){ length=0; }
~String( )
{ if(length>0){ delete[]entries; length=0; } }
String(const String&); // copy constructor
String(const char*); // conversion from C-string
String operator=(const String ©); //overloaded assignment operator
String &operator=(const char*copy); //overloaded assignment operator
const char *c_str( ) const; // conversion to C-style string
int size() { return length; }
int Find(const String &pat)const; // 在字符串中查找模式串pat, 找不到返回-1,否则返回pat在字符串中的位置
protected:
char *entries;
int length;
void setString(const char *copy); //auxiliary function
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -