-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathClassFeature.cpp
More file actions
39 lines (33 loc) · 1.22 KB
/
ClassFeature.cpp
File metadata and controls
39 lines (33 loc) · 1.22 KB
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
// ClassFeature.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
/*
* default
* C++11 provides more control over which methods are used.
* Suppose that you wish to use a defaulted function that,
* due to circumstances, isn’t created automatically. For example,
* if you provide a move constructor, then the default constructor,
* the copy constructor, and the copy assignment operator are not provided.
* In that case, you can use the keyword default to explicitly declare the defaulted versions of these methods:
*/
class Animal
{
public:
Animal() = default;
Animal(const Animal& animal) = default;
Animal& operator=(const Animal& animal) = default;
};
/*
* The compiler provides the same constructor that it would have provided automatically had you not provided the move constructor.
* The delete keyword, on the other hand, can be used to prevent the compiler from using a particular method. For example, to prevent an object from being copied, you can disable the copy constructor and copy assignment operator:
*/
class Animal
{
public:
Animal() = delete;
Animal(const Animal& animal) = delete;
};