-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy path0.cpp
More file actions
40 lines (34 loc) · 960 Bytes
/
Copy path0.cpp
File metadata and controls
40 lines (34 loc) · 960 Bytes
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
// d2mcpp: https://github.com/mcpp-community/d2mcpp
// license: Apache-2.0
// file: src/cpp11/tests/01-default-and-delete/0.cpp
//
// Exercise/练习: cpp11 | 01 - default and delete | 显示指定构造函数生成行为
//
// Tips/提示: 根据编译器提示使用`= default`和`= delete`修复错误
//
// Docs/文档:
// - https://en.cppreference.com/w/cpp/language/function#Function_definition
// - https://en.cppreference.com/w/cpp/language/function#Deleted_functions
//
// Auto-Checker/自动检测命令:
//
// d2x checker default-and-delete
//
import std;
import d2x;
// default和delete显式控制 -> 编译器默认构造函数的生成行为
struct A { };
struct B {
B(int x) { std::cout << "B(int x)" << std::endl; }
};
struct C {
C() { }
C(int x = 1) { std::cout << "C(int x = 1)" << std::endl; }
};
int main() { // 不要直接修改main函数中的代码
A a;
B b;
C c(1);
d2x::wait();
return 0;
}