-
Notifications
You must be signed in to change notification settings - Fork 1
/
String.h
49 lines (38 loc) · 947 Bytes
/
String.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// String.h
#ifndef _STRING_H
#define _STRING_H
class String {
public:
String(int capacity = 256);
String(const String& source);
~String();
String& operator=(const String& source);
char& GetAt(int index) const;
char& operator[](int index);
char* operator+(int index);
operator char*();
int GetLength() const;
int GetCapacity() const;
int Append(char ch);
int Append(char* pstr, int count);
int Insert(int index, char ch);
int Insert(int index, char* pstr, int count);
int Delete(int index, int count);
char* Mid(int first, int count);
char* Left(int count);
char* Right(int count);
private:
char (*front);
int capacity;
int length;
};
inline char& String::GetAt(int index) const {
return this->front[index];
}
inline int String::GetLength() const {
return this->length;
}
inline int String::GetCapacity() const {
return this->capacity;
}
#endif //_STRING_H