-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString.h
More file actions
71 lines (62 loc) · 2.1 KB
/
Copy pathString.h
File metadata and controls
71 lines (62 loc) · 2.1 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// String.h
#ifndef STRING_H
#define STRING_H
#include<iostream>
#include<cstdio>
#include<fstream>
using namespace std;
// Non member function prototype
unsigned int mystrlen(const char *ptr);
void mystrcpy(char*, const char*, int);
/*** String class implementation ***/
class String{
private:
char *str;
unsigned int length;
public:
/*** Constructor ***/
String(); // default
String(const char* p); // parameterised
String(String&& other); // move
String(String& t); // deep copy
~String();
/*** member function ***/
void getstr(void);
int len(void);
char* begin(void);
char* end(void);
/*** operator overloaded member function ***/
String& operator=(String& s2);
String& operator=(const char* ptr);
String& operator=(String&& other); // Move assignment
String operator +(String&);
String& operator +=(String&);
char& operator [](int i);
bool operator >(String s2);
bool operator <(String s2);
bool operator >=(String s2);
bool operator <=(String s2);
bool operator !=(String s2);
bool operator ==(String s2);
friend ostream& operator <<(ostream& out, String& obj);
friend istream& operator >>(istream& in, String& obj);
friend String operator+(String& obj, const char* ptr);
friend String operator+(const char* ptr, String& obj);
friend String operator+(String& obj, const char ch);
friend String operator+(const char ch, String& obj);
/*** friend function ***/
friend unsigned int my_strlen(String& s);
friend void my_strcpy(String& s1, String& s2);
friend void my_strncpy(String& dest, const String& src, unsigned const int len);
friend int my_strcmp(const String& s1, const String& s2);
friend void my_strcat(String& s1, const String& s2);
friend void my_strncat(String& s1, const String& s2, unsigned const int len);
friend String& my_strrev1(String& str);
friend void my_strrev2(String& startAddr, String& endAddr);
friend String& my_strupper(String& str);
friend String& my_strlower(String& str);
friend bool my_strchr(String& str, char ch);
friend bool my_strrchr(String& str, char ch);
friend bool my_strstr(const String& mainstr, const String& substr);
};
#endif // STRING_H