-
Notifications
You must be signed in to change notification settings - Fork 0
/
String.h
executable file
·41 lines (32 loc) · 1.03 KB
/
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
#ifndef __STRING_H_
#define __STRING_H_
#include <iostream>
namespace dstring {
class String
{
public:
/// ctor/dtor
String();
String(const wchar_t* s);
String(const String& s);
~String();
///
String& operator =(const String& s);
String& operator +=(wchar_t c);
/// ancillary functions
const wchar_t* c_str() const { return pStr; }
size_t size() const { return sz; }
private:
size_t sz; // number of characters
size_t space; // unused allocated space
wchar_t* pStr{ nullptr }; // points to the start of the character sequence
void copy_from(const String& x);
};
String& operator +=(String& a, const String& b);
String operator +(const String& a, const String& b);
std::wostream& operator <<(std::wostream& os, const String& s);
std::wistream& operator >>(std::wistream& is, String& s);
bool operator <(const String& a, const String& b);
bool operator >(const String& a, const String& b);
} // namespace dstring
#endif // __STRING_H_