Website Summary Files Commits Branches @commit @diff @stats
path: root / Week05 / Exercise02 / String.h
blob: f47b7c885c0f85e3684e505d2f7c1eed88703a61 (plain) (blame)
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
#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 */