-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString.h
More file actions
55 lines (44 loc) · 1.44 KB
/
String.h
File metadata and controls
55 lines (44 loc) · 1.44 KB
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
50
51
52
53
54
55
// ===========================================================================
// String.h
// ===========================================================================
#pragma once
#include <iostream>
class String
{
private:
char* m_ptr; // buffer
int m_len; // buffer length
public:
// c'tors and d'tor
String();
String(const char*);
String(const String&);
~String();
// public methods
int length() const;
bool insert(const String&, int);
bool remove(int, int);
void append(const String&);
String subString(int, int) const;
int find(const String&) const;
void toUpper();
void toLower();
String left(int) const;
String right(int) const;
// assignment operator
String & operator= (const String&);
// subscript operator
char& operator[] (int index);
// string concatenation
friend String operator+ (const String&, const String&);
friend const String & operator+= (String&, const String&);
// comparison operators
friend bool operator== (const String&, const String&);
friend bool operator!= (const String&, const String&);
// input/output
friend std::ostream & operator<< (std::ostream&, const String&);
friend std::istream & operator>> (std::istream&, String&);
};
// ===========================================================================
// End-of-File
// ===========================================================================