-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq_string.cpp
More file actions
35 lines (30 loc) · 726 Bytes
/
q_string.cpp
File metadata and controls
35 lines (30 loc) · 726 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
#include "q_string.h"
q_String::q_String(const char* s){
length = strlen(s);
buffer = new char[length + 1];
strcpy(buffer, s);
}
q_String::q_String(const q_String& s){
length = s.getLength();
buffer = new char[length + 1];
strcpy(buffer, s.getString());
}
q_String::~q_String(){
delete buffer;
}
void q_String::append(const char* s){
length += strlen(s);
char* temp = new char[length+1];
strcpy(temp, buffer);
strcat(buffer, s);
delete buffer;
buffer = temp;
}
void q_String::append(const q_String& s){
length += s.getLength();
char* temp = new char[length+1];
strcpy(temp, buffer);
strcat(buffer, s.getString());
delete buffer;
buffer = temp;
}