⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 string.hpp

📁 本软件实现了模拟cpu的基本工作原理和工作过程
💻 HPP
字号:
#ifndef __String_hpp
#define __String_hpp

#include "List.hpp"
#include <string.h>
#include <fstream.h>
class String{
public:
	//构造函数
	String();
	String(const String& other);
	String(const char* string);
	String(List<char>& list);
	//重载赋值运算符=
	String& operator = (const String& other);
	//析构函数
	~String();
	//功能函数
	const char * c_str()const;//用此函数获取的char*变量不能改动,且在String做了其他操作之后可能就无法正常使用
	int get_length();
	//重载运算符
	char& operator [](int index)const;
	friend istream& operator>>(istream& stream,String& s);
	void GetSecretKey();
	friend ostream& operator<<(ostream& stream,String& s);
protected:
	char *entries;//串首指针
	int length;//串长度
};

//串比较:按字典顺序
bool operator == (const String& first,const String& second);
bool operator  > (const String& first,const String& second);
bool operator  < (const String& first,const String& second);
bool operator >= (const String& first,const String& second);
bool operator <= (const String& first,const String& second);
bool operator != (const String& first,const String& second);
//串操作
void strcat(String& first,const String& second);
void strcpy(String& first,const String& second);
void strncpy(String& first,const String& second,int n);//从second复制n个字符到first,n<=0不做任何操作,n大于second的长度则把second复制到first
int strstr(const String& text,const String& target);
//串输入
String read_in(ifstream& input,int& terminator);//terminator 记录了本次输入的结束符
//串输出
void write(ofstream& output,String& s);

#endif



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -