From 571dc57f812a685bda7bd3baf8aaf2ef56feae65 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 28 Mar 2026 16:19:58 +0200 Subject: feat(Week05): Add solutions --- Week05/Exercise02/String.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Week05/Exercise02/String.h (limited to 'Week05/Exercise02/String.h') diff --git a/Week05/Exercise02/String.h b/Week05/Exercise02/String.h new file mode 100644 index 0000000..f47b7c8 --- /dev/null +++ b/Week05/Exercise02/String.h @@ -0,0 +1,32 @@ +#ifndef _STRING +#define _STRING + +class String { + char* str; + // Не е нужно да пазим и дължината като атрибут, + // можем винаги да си я смятаме с strlen, но + // е по-културно така + unsigned length; + + void free(); + void copyFrom(const String& other); + +public: + String(); + ~String(); + String(const String& other); + String& operator=(const String& other); + + String(String&& other); + String& operator=(String&& other); + + String(const char* str); + String Substring(unsigned startIndex, unsigned length) const; + void Concat(const String& end); + + /* Помощна функция */ + + unsigned CountWords() const; +}; + +#endif /* _STRING */ -- cgit v1.3.1-23-gd82d