Quay lại Khóa học
AI013 Nghề nghiệp

Hướng dẫn C++ hiện đại

Hướng dẫn này nhằm cung cấp cho các nhà phát triển có kinh nghiệm một tài liệu tham khảo nhanh về các tính năng mới của C++11/14/17/20. Nó bao gồm các cải tiến về khả năng sử dụng ngôn ngữ, hiệu suất tại thời điểm chạy, các cấu trúc dữ liệu mới, con trỏ thông minh và quản lý bộ nhớ, biểu thức chính quy, lập trình đồng thời, và phần giới thiệu trước về C++20.

4.8
30.0h
318 học viên
10 lessons
2 lượt thích
Trí tuệ nhân tạo
Bắt đầu học

Tổng quan khóa học

📚 Tóm tắt nội dung

Hướng dẫn này được thiết kế nhằm cung cấp cho các nhà phát triển có kinh nghiệm một tài liệu tham khảo nhanh về các tính năng mới trong C++11/14/17/20. Nội dung bao gồm cải tiến về khả năng sử dụng ngôn ngữ, hiệu suất tại thời điểm chạy, cách sử dụng các container mới, con trỏ thông minh và quản lý bộ nhớ, biểu thức chính quy, lập trình đồng thời, cùng với cái nhìn tổng quan về C++20.

Nhanh chóng làm chủ C++11/14/17/20 và bước qua cánh cửa của lập trình C++ hiện đại.

Tác giả: Âu Trường Khôn (Ou Changkun)

Ghi nhận: Được cấp phép theo điều khoản CC BY-NC-ND 4.0, xin cảm ơn tất cả các nhà đóng góp trên GitHub và cộng đồng hỗ trợ liên quan.

🎯 Mục tiêu học tập

  1. Nhận diện và xác minh môi trường biên dịch C++ và kiến trúc mục tiêu bằng công cụ dòng lệnh.
  2. Giải thích sự tương thích chuẩn và lịch sử chồng chéo giữa C (C89, C99, C11) và C++ (C++98, C++1x).
  3. Triển khai việc liên kết xuyên ngôn ngữ thành công bằng cách sử dụng tiêu đề extern "C" và quy trình biên dịch đa giai đoạn.
  4. Giải quyết sự mơ hồ của con trỏ bằng nullptr và triển khai logic tại thời điểm biên dịch bằng constexprif constexpr.
  5. Đơn giản hóa các khai báo phức tạp bằng auto, decltype, và đặt tên kiểu (using) trong khi đảm bảo thiết kế hướng đối tượng vững chắc nhờ overridefinal.
  6. Thiết kế mã nguồn mang tính tổng quát cao bằng các mẫu biến số, biểu thức gập (fold expressions), và suy luận tham số mẫu không phải kiểu.
  7. Xác định và triển khai biểu thức Lambda với các chế độ bắt giá trị khác nhau (Giá trị, Tham chiếu, Biểu thức, và Tổng quát).
  8. Sử dụng std::functionstd::bind để tạo các bao bọc hàm linh hoạt và ứng dụng hàm một phần.
  9. Phân loại biểu thức thành Lvalues, Prvalues và Xvalues, và áp dụng cơ chế chuyển động (Move Semantics) để tối ưu hóa quản lý tài nguyên lớp.
  10. Phân biệt mô hình bộ nhớ và các trường hợp sử dụng của std::array (kích thước cố định, ngăn xếp) và std::vector (kích thước động, vùng nhớ heap).

Bài học

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.