c/c++课的作业合集,都是很简单的文件。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

49 lines
1.0 KiB

//
// Created by lenfrex on 2022/4/4.
//
#ifndef WORK20220401_CSTRING_H
#define WORK20220401_CSTRING_H
#include <iostream>
#include "utility"
using namespace std::rel_ops;
class CString {
private:
// 字符数组做字符串
char *data = nullptr;
// 字符串实际长度
int length = 0;
// 已分配的字符数量
int allocSize = 0;
public:
explicit CString(int size);
CString(char *data, int length);
explicit CString(char *source);
CString(const CString &source);
CString();
~CString();
bool operator==(const CString &source) const;
bool operator>(const CString &compareString) const;
CString &operator+=(const CString &source);
CString &operator=(const CString &source);
friend std::ostream &operator<<(std::ostream &outputStream, const CString &source);
friend std::istream &operator>>(std::istream &outputStream, CString &source);
char operator[](int i);
};
#endif //WORK20220401_CSTRING_H