Website Summary Files Commits Branches @commit @diff @stats
path: root / src / String
diff options
context:
space:
mode:
2 files changed, 16 insertions, 1 deletions
-rw-r--r--src/String/String.cpp13
-rw-r--r--src/String/String.h4
diff --git a/src/String/String.cpp b/src/String/String.cpp
new file mode 100644
index 0000000..f94dce2
--- /dev/null
+++ b/src/String/String.cpp
@@ -0,0 +1,13 @@
+#include "String.h"
+#include <cstring>
+
+/* Private */
+
+void String::free() {
+ delete[] str;
+}
+
+void String::copyFrom(const String& other) {
+ this->str = new char[other.length];
+ strcpy(this->str, other.str);
+}
diff --git a/src/String/String.h b/src/String/String.h
index 4accaef..acf3650 100644
--- a/src/String/String.h
+++ b/src/String/String.h
@@ -2,7 +2,7 @@
#define HEADER_STRING
class String {
- char* elems;
+ char* str;
unsigned count;
unsigned length;
@@ -11,6 +11,8 @@ class String {
void moveFrom(String&& other);
public:
+ String(const char* str);
+
String();
String(const String& other);
String& operator=(const String& other);