Torna ai corsi
AI013 Professionale

Tutorial su C++ Moderno

Questo tutorial ha lo scopo di fornire ai programmatori esperti un riferimento rapido alle nuove funzionalità di C++11/14/17/20. Copre miglioramenti nell'usabilità del linguaggio, ottimizzazioni in fase di esecuzione, nuovi contenitori, puntatori intelligenti e gestione della memoria, espressioni regolari, programmazione concorrente e una preview di C++20.

4.8
30.0h
318 studenti
10 lessons
2 mi piace
Intelligenza Artificiale
Inizia ad imparare

Panoramica del corso

📚 Riepilogo del contenuto

Questo tutorial è stato progettato per fornire agli sviluppatori esperti un riferimento rapido alle nuove funzionalità di C++11/14/17/20. Il contenuto copre miglioramenti nell'usabilità linguistica, ottimizzazioni a runtime, l'utilizzo di nuovi contenitori, puntatori intelligenti e gestione della memoria, espressioni regolari, programmazione concorrente e una preview di C++20.

Fai rapidamente il punto su C++11/14/17/20 e attraversa la porta d'ingresso verso la programmazione moderna in C++.

Autore: 欧长坤 (Ou Changkun)

Ringraziamenti: Rilasciato sotto licenza CC BY-NC-ND 4.0, grazie a tutti i contributori GitHub e alla comunità correlata.

🎯 Obiettivi di apprendimento

  1. Identificare e verificare l'ambiente del compilatore C++ e l'architettura target utilizzando strumenti da riga di comando.
  2. Spiegare la compatibilità standard e la storia sovrapposta tra C (C89, C99, C11) e C++ (C++98, C++1x).
  3. Implementare il collegamento interlingua funzionale usando intestazioni extern "C" e flussi di compilazione a più fasi.
  4. Risolvere l'ambiguità dei puntatori con nullptr e implementare logica a tempo di compilazione con constexpr e if constexpr.
  5. Semplificare dichiarazioni complesse con auto, decltype e alias di tipo (using), garantendo un design orientato agli oggetti robusto con override e final.
  6. Progettare codice altamente generico utilizzando template variadici, espressioni fold e deduzione dei parametri template non tipici.
  7. Definire e implementare espressioni Lambda con diversi modi di cattura (Valore, Riferimento, Espressione e Generico).
  8. Utilizzare std::function e std::bind per creare wrapper funzionali flessibili e applicazioni parziali di funzioni.
  9. Classificare le espressioni in Lvalues, Prvalues e Xvalues, e applicare la semantica di spostamento per ottimizzare la gestione delle risorse della classe.
  10. Distinguere tra i modelli di memoria e i casi d'uso di std::array (dimensione fissa, stack) e std::vector (dimensione dinamica, heap).

Lezioni

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.