From 2aef2b9bd968b77a70ddeac879b4b284bbb73548 Mon Sep 17 00:00:00 2001 From: Joeyeahyeah Date: Wed, 21 Jan 2026 13:13:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8D=E9=94=99=E7=9A=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dslings/en/hello-mcpp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dslings/en/hello-mcpp.cpp b/dslings/en/hello-mcpp.cpp index a9cb54f..fbffc03 100644 --- a/dslings/en/hello-mcpp.cpp +++ b/dslings/en/hello-mcpp.cpp @@ -34,17 +34,17 @@ int main() { - std::cout << "hello, mcpp!" << std:endl; // 0. Fix this compilation error + std::cout << "hello, mcpp!" << std::endl; // 0. Fix this compilation error - int a = 1.1; // 1. Fix this runtime error, change int to double to pass the check + double a = 1.1; // 1. Fix this runtime error, change int to double to pass the check d2x_assert_eq(a, 1.1); // 2. Runtime checkpoint, need to fix code to pass all checkpoints (cannot directly delete checkpoint code) - D2X_YOUR_ANSWER b = a; // 3. Fix this compilation error, give b an appropriate type + int b = a; // 3. Fix this compilation error, give b an appropriate type d2x_assert_eq(b, 1); // 4. Runtime checkpoint 2 - D2X_WAIT // 5. Delete or comment out this macro to proceed to the next exercise (project formal code practice) + // D2X_WAIT // 5. Delete or comment out this macro to proceed to the next exercise (project formal code practice) return 0; } From 2f7e59d21f21fd473866e93dd8080c8feb143279 Mon Sep 17 00:00:00 2001 From: Joeyeahyeah Date: Wed, 21 Jan 2026 14:30:53 +0800 Subject: [PATCH 2/2] complete - auto, decltype --- dslings/en/cpp11/00-auto-and-decltype-0.cpp | 10 +++++----- dslings/en/cpp11/00-auto-and-decltype-1.cpp | 10 +++++----- dslings/en/cpp11/00-auto-and-decltype-2.cpp | 6 +++--- dslings/en/cpp11/00-auto-and-decltype-3.cpp | 4 ++-- dslings/en/cpp11/00-auto-and-decltype-4.cpp | 12 ++++++------ 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/dslings/en/cpp11/00-auto-and-decltype-0.cpp b/dslings/en/cpp11/00-auto-and-decltype-0.cpp index 95b993f..10bb6fa 100644 --- a/dslings/en/cpp11/00-auto-and-decltype-0.cpp +++ b/dslings/en/cpp11/00-auto-and-decltype-0.cpp @@ -26,21 +26,21 @@ int main() { int a = 1; auto a1 = a; // a1's type is int int b = 2; - D2X_YOUR_ANSWER b1 = b; + int b1 = b; decltype(b) b2 = b; // b2's type is int - D2X_YOUR_ANSWER a2 = a; + int a2 = a; char c = 'c'; - D2X_YOUR_ANSWER c1 = c; - D2X_YOUR_ANSWER c2 = c; + int c1 = c; + int c2 = c; d2x_assert_eq(a, a1); d2x_assert_eq(a1, a2); d2x_assert_eq(b, b1); d2x_assert_eq(b1, b2); - D2X_WAIT + // D2X_WAIT return 0; } diff --git a/dslings/en/cpp11/00-auto-and-decltype-1.cpp b/dslings/en/cpp11/00-auto-and-decltype-1.cpp index 1de29ba..b6c3029 100644 --- a/dslings/en/cpp11/00-auto-and-decltype-1.cpp +++ b/dslings/en/cpp11/00-auto-and-decltype-1.cpp @@ -26,22 +26,22 @@ int main() { // 1. Expressions int a = 1; auto a1 = a + 2; - D2X_YOUR_ANSWER a2 = a + 2 + 1.1; + double a2 = a + 2 + 1.1; int b = 2; - D2X_YOUR_ANSWER b1 = a + 0.1; + double b1 = a + 0.1; decltype(a + b + 1.1) b2 = a + b + 1.1; char c = 'c'; - D2X_YOUR_ANSWER c1 = 1 + c; - D2X_YOUR_ANSWER c2 = 2 + 'a'; + char c1 = 1 + c; + char c2 = 2 + 'a'; d2x_assert_eq(a2, a + 2 + 1.1); d2x_assert_eq(b1, a + 0.1); d2x_assert_eq(c1, 1 + c); d2x_assert_eq(c2, 2 + 'a'); - D2X_WAIT + // D2X_WAIT return 0; } diff --git a/dslings/en/cpp11/00-auto-and-decltype-2.cpp b/dslings/en/cpp11/00-auto-and-decltype-2.cpp index 7b23111..c6c962d 100644 --- a/dslings/en/cpp11/00-auto-and-decltype-2.cpp +++ b/dslings/en/cpp11/00-auto-and-decltype-2.cpp @@ -40,7 +40,7 @@ int main() { } std::cout << std::endl; - D2X_YOUR_ANSWER v2 = v.begin(); + std::vector::iterator v2 = v.begin(); for (; v2 != v.end(); ++v2) { std::cout << *v2 << " "; } @@ -48,7 +48,7 @@ int main() { auto minus_func = [](int a, int b) { return a - b; }; - std::vector> funcVec = { + std::vector> funcVec = { add_func, minus_func }; @@ -56,7 +56,7 @@ int main() { d2x_assert_eq(funcVec[0](1, 2), 3); d2x_assert_eq(funcVec[1](1, 2), -1); - D2X_WAIT + // D2X_WAIT return 0; } diff --git a/dslings/en/cpp11/00-auto-and-decltype-3.cpp b/dslings/en/cpp11/00-auto-and-decltype-3.cpp index 6c15322..c3fd471 100644 --- a/dslings/en/cpp11/00-auto-and-decltype-3.cpp +++ b/dslings/en/cpp11/00-auto-and-decltype-3.cpp @@ -30,7 +30,7 @@ auto add_func(int a, double b) -> decltype(a + b) { } template -D2X_YOUR_ANSWER minus_func(T1 a, T2 b) -> D2X_YOUR_ANSWER { +auto minus_func(T1 a, T2 b) -> auto { return a - b; } @@ -40,7 +40,7 @@ int main() { d2x_assert_eq(minus_func(2, 1), 1); d2x_assert_eq(minus_func(1, 2.1), -1.1); - D2X_WAIT + // D2X_WAIT return 0; } diff --git a/dslings/en/cpp11/00-auto-and-decltype-4.cpp b/dslings/en/cpp11/00-auto-and-decltype-4.cpp index 329b6bb..0070c2b 100644 --- a/dslings/en/cpp11/00-auto-and-decltype-4.cpp +++ b/dslings/en/cpp11/00-auto-and-decltype-4.cpp @@ -39,22 +39,22 @@ int main() { // Type deduction for obj and (obj) type_check = std::is_same::value; d2x_assert(type_check); type_check = false; // dont change this line - type_check = std::is_same::value; + type_check = std::is_same::value; d2x_assert(type_check); type_check = false; // dont change this line // Type deduction for obj.a and (obj.a) - type_check = std::is_same::value; + type_check = std::is_same::value; d2x_assert(type_check); type_check = false; // dont change this line - type_check = std::is_same::value; + type_check = std::is_same::value; d2x_assert(type_check); type_check = false; // dont change this line // Type deduction for obj.b and (obj.b) - type_check = std::is_same::value; + type_check = std::is_same::value; d2x_assert(type_check); type_check = false; // dont change this line - type_check = std::is_same::value; + type_check = std::is_same::value; d2x_assert(type_check); type_check = false; // dont change this line - D2X_WAIT + // D2X_WAIT return 0; }