-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyClass.h
43 lines (34 loc) · 1.05 KB
/
MyClass.h
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
#pragma once
#include <ostream>
#include <string>
#define COPY_SEMANTIC 0
#define MOVE_SEMANTIC 0
namespace af
{
class MyClass
{
public:
MyClass(); // Default constructor
MyClass(const char *); // Contructor
~MyClass(); // Destructor
#if COPY_SEMANTIC
MyClass(const MyClass &); // Copy constructor
MyClass &operator=(const MyClass &); // Copy assignment operator
#else
MyClass(const MyClass &) = delete;
MyClass &operator=(const MyClass &) = delete;
#endif
#if MOVE_SEMANTIC
MyClass(MyClass &&) noexcept; // Move constructor
MyClass &operator=(MyClass &&) noexcept; // Move assignment operator
#else
MyClass(MyClass &&) noexcept = delete;
MyClass &operator=(MyClass &&) noexcept = delete;
#endif
friend void swap(MyClass &first, MyClass &second) noexcept;
std::string getMsg() const;
private:
char *mMsg;
};
std::ostream& operator<<(std::ostream& os, const MyClass& rhs);
} // namespace af