-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathString.h
34 lines (28 loc) · 896 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
#ifndef __STRING_H
#define __STRING_H
#include <cstddef>
#include <iostream>
class String {
public:
// default constructor
String() : len(0), str(nullptr) {};
// constructor from c-string
String(const char *s);
// constructor of copy
String(const String& s);
// move constructor
String(String&& s) noexcept;
~String();
size_t size() const;
char& operator[](size_t pos);
String& operator=(const String& s);
String& operator+=(const String& s);
String operator+(String& s);
friend std::ostream& operator<<(std::ostream& os, String& s);
friend std::ostream& operator<<(std::ostream& os, String&& s);
friend std::istream& operator>>(std::istream& is, String& s);
private:
size_t len;
char* str;
};
#endif /* __STRING_H */