--- title: Modern C++ Programming tags: computer science, algorithm, data structure, leetcode, c++ --- <center> # <font size = 6>Modern C++ Programming</font> </center> <center> :::info Location: TBD, 德田館 Time: TBA ::: </center> <br> <br> <div> <p style="text-align: right"> ``C++ is a beast that cannot be tamed completely.<br>But in its <font color = "red">complexities</font> lie its power.''<br>-- Bjarne Stroustrup </p> </div> <div> <p style="text-align: right"> ``C++'s power is directly proportional to its complexity.''<br>-- Alexander Stepanov </p> </div> <div> <p style="text-align: right"> ``The key to mastering C++ is to focus on the concepts<br>rather than getting lost in language technicalities.''<br>-- Scott Meyers </p> </div> ## **Course Information** The course aims to delve deep into the modern features and best practices of C++ programming, equipping students and professionals with the skills needed to develop efficient and robust applications using C++2x standards. ### Instructor - Instructor name: 盧政良 (Zheng-Liang Lu, Arthur) - Email address: arthurzllu@gmail.com ### Prerequisites - Proficiency in C++, including concepts of loops, arrays, pointers, functions, and structures. - See also [APCS: C++ Programming](https://www.csie.ntu.edu.tw/~d00922011/cpp.html). - Familiarity with other programming languages (Java or C#) is advantageous. - See also [Java Programming](https://www.csie.ntu.edu.tw/~d00922011/java.html). - See also [C# Programming](https://www.csie.ntu.edu.tw/~d00922011/csharp.html). ### Tech Stack - C\+\+2x compatible with C++11, 14, 17, 20. - Tool chains - Compilers: [GNU g++](https://gcc.gnu.org/) or [clang](https://clang.llvm.org/) - make, cmake - Debugger: gdb - Version control: git - [Linux kernel document](https://docs.kernel.org/admin-guide/README.html) ### Recording Classroom Lectures Policy :::warning Recording of classroom lectures is <font color="red">**prohibited**</font> unless advance written permission is obtained from the class instructor and any guest presenter(s). ::: ## **Syllabus** ### Introduction to C++2x - Brief history and overview of C\+\+2x features - Key features and advantages of C\+\+2x over C - Basic syntax and data types in C\+\+2x ### Object-Oriented Programming - Classes and objects - Encapsulation and access specifiers (public, private, protected, and friend) - Constructors and destructors - Inheritance and polymorphism - Virtual functions and pure virtual functions - Operator overriding - Abstract classes and interfaces - Annoymous function: lambda - Using OOP to model real-world problems - Exception handling ### Templates and Standard Template Library (STL) - Templates and generic programming - Class templates and function templates - Standard Template Library (STL): containers, iterators, algorithms - Using STL containers and algorithms to solve common problems ### C++ Standard Library - IOStream Library: input and output streams, stream manipulators - String and character manipulation: string, char_traits, charconv - Time and date manipulation: chrono, calendar, time_zone - Filesystem Library: file and directory manipulation ### Memory Management - Dynamic memory allocation and deallocation in C++ - Smart pointers: unique_ptr, shared_ptr, weak_ptr - RAII (Resource Acquisition Is Initialization) pattern - Handling memory leaks and other memory-related issues ### Design Patterns - Creational patterns: singleton, factory method, abstract factory - Structural patterns: adapter, bridge, proxy, decorator, sharing (interning, flyweight) - Behavioral patterns: iterator, strategy, observer (publish/subscribe) - Application: QunatLib ### C++ Boost Library - Introduction to the Boost library - Selecting and using relevant Boost components - Boost.Asio - Boost integration with C++20 and embedded systems ### Multithreading Programming - Basic concepts of operating systems (OS) - Thread & Runnable - Race condition, mutual exclusion & synchronized methods/blocks - Producer-consumer problem (bounded-buffer problem) & semaphores - Dining philosophers: deadlock, livelock, starvation - High-level concurrency framework: thread pools, fork-join pools, asynchronous computation, concurrent data structures, atomic variables, synchronizers, monitor locks ## **Gradebook** <center> <iframe src="" width = "700px" height = "100px"></iframe> </center> ## **References** ### ++C\+\+ Programming Language++ - Josh Lospinoso, *C++ Crash Course: A Fast-Paced Introduction*, 2019 ![](https://i.imgur.com/WsJQO1f.jpg =100x) - Official website: https://ccc.codes/ - [CppNow](https://www.youtube.com/watch?v=nBUgjFPkoto) ![image](https://hackmd.io/_uploads/H13ycdKvA.png =100x) #### Object-Oriented Programming & Design Patterns #### C++ Boost - Boris Schäling, [The Boost C++ Libraries](https://theboostcpplibraries.com/), 2024 - Arindam Mukherjee, [Learning Boost C++ Libraries](https://www.amazon.com/Learning-Boost-Libraries-Arindam-Mukherjee/dp/1783551216), 2015 ![image](https://hackmd.io/_uploads/HyecyNVPA.png =100x) #### C++ STL - John Farrier, [Data Structures and Algorithms with the C++ STL: A guide for modern C++ practitioners](https://www.amazon.com/Data-Structures-Algorithms-STL-practitioners/dp/1835468551), 2024 ![image](https://hackmd.io/_uploads/ByIupQVv0.png =100x) #### Concurrent Programming - Rainer Grimm, [Concurrency with Modern C++](https://leanpub.com/concurrencywithmodernc), 2024 ![image](https://hackmd.io/_uploads/SkPp6Q4PR.png =100x) ### ++Applications++ #### Linux Kernel Development - https://www.kernel.org/ - https://github.com/torvalds/linux - Jim Huang (黃敬群), [Linux 核心設計 (Linux Kernel Internals)](http://wiki.csie.ncku.edu.tw/linux/schedule), Department of Computer Science and Information Engineering, National Cheng Kung University #### CUDA - https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html - Jaegeun Han and Bharatkumar Sharma, [Learn CUDA Programming](https://www.amazon.com/CUDA-Cookbook-Effective-parallel-programming/dp/1788996240), 2019 ![image](https://hackmd.io/_uploads/BJzjnQVP0.png =100x) #### QuantLib - https://www.quantlib.org/ - M. S. Joshi, *C++ Design Patterns and Derivatives Pricing*, 2008 ![](https://i.imgur.com/DV4se18.png =100x)