กลับสู่คอร์สเรียน
AI013 มืออาชีพ

คู่มือ C++ สมัยใหม่

คู่มือการเรียนนี้มีวัตถุประสงค์เพื่อให้ผู้พัฒนาที่มีประสบการณ์ได้รับข้อมูลอ้างอิงอย่างรวดเร็วเกี่ยวกับคุณสมบัติใหม่ของ C++11/14/17/20 โดยครอบคลุมการปรับปรุงด้านความสามารถในการใช้งานของภาษา ประสิทธิภาพในช่วงเวลาทำงาน โครงสร้างข้อมูลใหม่ ตัวชี้อัจฉริยะและการจัดการหน่วยความจำ การจัดรูปแบบแบบสม่ำเสมอ การเขียนโปรแกรมแบบขนาน และบทนำสำหรับ C++20

4.8
30.0h
318 ผู้เรียน
10 lessons
2 การถูกใจ
ปัญญาประดิษฐ์
เริ่มเรียน

ภาพรวมคอร์สเรียน

📚 สรุปเนื้อหา

คู่มือการเรียนนี้ออกแบบมาเพื่อให้ผู้พัฒนาที่มีประสบการณ์ได้ใช้เป็นแนวทางย่อสำหรับคุณสมบัติใหม่ของ C++11/14/17/20 โดยเนื้อหาครอบคลุมการปรับปรุงด้านความสะดวกในการใช้งานของภาษา การปรับปรุงประสิทธิภาพในเวลาทำงาน การใช้คอนเทนเนอร์ใหม่ ชี้แจงตัวชี้วัดและจัดการหน่วยความจำ แบบแสดงรูปแบบ (Regular Expressions) การเขียนโปรแกรมแบบขนาน และการทบทวนลักษณะสำคัญของ C++20

เรียนรู้อย่างรวดเร็วเกี่ยวกับ C++11/14/17/20 และก้าวข้ามสู่โลกของการเขียนโปรแกรมแบบสมัยใหม่ของภาษา C++

ผู้เขียน: โอ่ว เฉียงกุน (Ou Changkun)

คำขอบคุณ: อนุญาตภายใต้ข้อกำหนดแบบ CC BY-NC-ND 4.0 ขอขอบคุณผู้มีส่วนร่วมทุกคนบน GitHub และชุมชนสนับสนุนที่เกี่ยวข้อง

🎯 เป้าหมายการเรียนรู้

  1. ระบุและตรวจสอบสภาพแวดล้อมคอมไพเลอร์ C++ และสถาปัตยกรรมเป้าหมายโดยใช้เครื่องมือจากบรรทัดคำสั่ง
  2. อธิบายความเข้ากันได้ของมาตรฐานและประวัติที่ทับซ้อนกันระหว่างภาษา C (C89, C99, C11) และภาษา C++ (C++98, C++1x)
  3. ใช้หัวไฟล์ extern "C" และกระบวนการคอมไพล์หลายขั้นตอน เพื่อจัดการการเชื่อมต่อข้ามภาษาอย่างมีประสิทธิภาพ
  4. แก้ไขความไม่แน่นอนของตัวชี้ (pointer ambiguity) โดยใช้ nullptr และใช้ constexpr และ if constexpr เพื่อสร้างตรรกะในขณะคอมไพล์
  5. ลดความซับซ้อนของคำประกาศโดยใช้ auto, decltype, และการตั้งชื่อประเภท (using) พร้อมรักษาหลักการออกแบบเชิงวัตถุที่แข็งแรงด้วย override และ final
  6. ออกแบบโค้ดที่มีความยืดหยุ่นสูงโดยใช้เทมเพลตแบบตัวแปร (variadic templates), นิพจน์แบบพับ (fold expressions), และการอนุมานพารามิเตอร์เทมเพลตที่ไม่ใช่ประเภท (non-type template parameter deduction)
  7. กำหนดและดำเนินการใช้ฟังก์ชันลัมบ์ (Lambda expressions) โดยใช้โหมดการจับข้อมูลต่างๆ (ค่า, ค่าอ้างอิง, นิพจน์, และทั่วไป)
  8. ใช้ std::function และ std::bind เพื่อสร้างฟังก์ชันที่ยืดหยุ่นและแอปพลิเคชันฟังก์ชันบางส่วน
  9. แยกประเภทนิพจน์ออกเป็น Lvalues, Prvalues, และ Xvalues และนำแนวคิดการเคลื่อนย้ายทรัพยากร (Move Semantics) มาใช้เพื่อเพิ่มประสิทธิภาพการจัดการทรัพยากรในคลาส
  10. แยกแยะโมเดลหน่วยความจำและกรณีใช้งานของ std::array (ขนาดคงที่, บนสแต็ก) กับ std::vector (ขนาดเปลี่ยนแปลงได้, บนฮีป)

บทเรียน

Lesson

This lesson explores the evolution of C++ and the importance of adopting modern, type-safe coding practices over legacy C-style habits. Students will learn to utilize explicit casting operators and compiler diagnostics to improve code stability, security, and performance.

This lesson explores modern C++ language usability by addressing the "NULL Trap" through the introduction of `nullptr` and examining how `constexpr` and `noexcept` shift computation and error handling to compile-time. Students will learn to improve code safety and performance by replacing legacy C-style macros and casts with modern, type-safe alternatives.

This lesson explores performance optimization in modern C++ through move semantics, lambda expressions, and efficient memory management. Students will learn to leverage zero-cost abstractions like std::array and SFINAE to improve code performance and type safety in resource-constrained environments.

This lesson explores the transition from legacy C-style arrays to the modern std::array, highlighting how the latter provides type safety and STL integration without sacrificing performance. Students will learn to leverage stack-based memory allocation, bounds-checking, and perfect forwarding to write more efficient and robust C++ code.

This lesson explores the pitfalls of manual memory management, such as memory leaks and dangling pointers, and introduces RAII (Resource Acquisition Is Initialization) as a safer, automated alternative. Students will learn how to utilize smart pointers like std::unique_ptr, std::shared_ptr, and std::weak_ptr to ensure deterministic resource cleanup and exception safety in modern C++.

This lesson explores the transition from imperative, manual string searching to declarative pattern matching using regular expressions and formal grammars. Students will learn to apply regex metacharacters and anchors to efficiently parse unstructured data while understanding the performance benefits of using Deterministic Finite Automata.

This lesson explores the transition to standardized concurrency in C++11, which introduced a formal memory model and native thread support to replace platform-specific APIs. Students will learn to manage thread lifecycles, ensure cross-platform data consistency with standardized types, and use the noexcept specifier to maintain program stability in multi-threaded environments.

This lesson explores the evolution of C++ from platform-specific coding to a unified, high-level abstraction layer, focusing on the transition from legacy macros to modern standards. Students will learn to leverage C++11 concurrency features and C++23 filesystem utilities to write portable, maintainable code that avoids OS-specific dependencies.

This lesson explores modernizing C++ development by transitioning from platform-specific APIs to standardized, high-level abstractions like task-based parallelism and the C++11 memory model. Students will learn to improve code maintainability and safety by utilizing features such as std::future, std::atomic, and extended integer types like long long int.

This lesson explores the evolution of C++20, focusing on the "Big Four" features—Concepts, Modules, Coroutines, and Ranges—that shift the language toward a more declarative and efficient programming model. Students will learn how these tools improve code safety, reduce build times, and replace complex template metaprogramming with clearer, constrained syntax.