Back to Courses
AI013 Professional

Modern C++ Tutorial

This tutorial aims to provide experienced developers with a quick reference to the new features of C++11/14/17/20. It covers language usability enhancements, runtime improvements, new containers, smart pointers and memory management, regular expressions, concurrent programming, and a preview of C++20.

4.8
30.0h
318 students
2 likes
Artificial Intelligence
Start Learning

Lessons

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.

Course Overview

📚 Content Summary

This tutorial is designed to provide experienced developers with a quick reference to the new features of C++11/14/17/20. The content covers language usability enhancements, runtime improvements, the use of new containers, smart pointers and memory management, regular expressions, concurrent programming, and a preview of C++20.

Quickly get up to speed with C++11/14/17/20 and step through the gateway to modern C++ programming.

Author: 欧长坤 (Ou Changkun)

Acknowledgments: 采用 CC BY-NC-ND 4.0 协议授权,致谢所有 GitHub 贡献者及相关社区支持。

🎯 Learning Objectives

  1. Identify and verify the C++ compiler environment and target architecture using command-line tools.
  2. Explain the standard compatibility and overlapping history between C (C89, C99, C11) and C++ (C++98, C++1x).
  3. Implement functional cross-language linking by using extern "C" headers and multi-stage compilation workflows.
  4. Resolve pointer ambiguity using nullptr and implement compile-time logic using constexpr and if constexpr.
  5. Simplify complex declarations using auto, decltype, and type aliasing (using) while ensuring robust object-oriented design with override and final.
  6. Design highly generic code using variadic templates, fold expressions, and non-type template parameter deduction.
  7. Define and implement Lambda expressions using various capture modes (Value, Reference, Expression, and Generic).
  8. Utilize std::function and std::bind to create flexible function wrappers and partial function applications.
  9. Categorize expressions into Lvalues, Prvalues, and Xvalues, and apply Move Semantics to optimize class resource management.
  10. Differentiate between the memory models and use cases of std::array (fixed size, stack) and std::vector (dynamic size, heap).

Lessons