-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString.h
More file actions
35 lines (28 loc) · 737 Bytes
/
String.h
File metadata and controls
35 lines (28 loc) · 737 Bytes
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
#ifndef STRING_H
#define STRING_H
#include <iostream>
#define GROW 2
class String {
friend std::ostream& operator<<(std::ostream &os, const String &s);
friend std::istream& operator>>(std::istream &is, String &s);
friend String operator+(const String &a, const String &b);
public:
String();
String(const char *s);
String(char c);
String(const String &s);
~String();
String substring(size_t pos = 0, size_t len = npos) const;
char operator[](size_t i) const;
const String& operator=(const String& s);
bool operator==(const String &s) const;
const char* cstring() const;
size_t len();
void shrink();
private:
void grow();
char *cstr;
size_t size, max;
static const size_t npos = -1;
};
#endif