C++ Primer, Bản thứ năm
Một hướng dẫn toàn diện và đáng tin cậy về C++, được viết lại hoàn toàn cho chuẩn C++11. Khóa học này bao quát mọi thứ từ các yếu tố cơ bản của ngôn ngữ đến các tiện ích thư viện phức tạp và các công cụ nâng cao trong việc xây dựng lớp.
Tổng quan khóa học
📚 Tóm tắt Nội dung
Hướng dẫn toàn diện và uy tín về C++, được viết lại hoàn toàn cho chuẩn C++11. Khóa học này bao quát mọi thứ từ các yếu tố cơ bản của ngôn ngữ đến các tiện ích thư viện phức tạp và các công cụ nâng cao để xây dựng lớp.
Tài liệu tiêu chuẩn ngành chính xác nhất để thành thạo lập trình C++ hiện đại theo chuẩn C++11.
Tác giả: Stanley B. Lippman, Josée Lajoie, Barbara E. Moo
Lời cảm ơn: Dave Abrahams, Andy Koenig, Stephan T. Lavavej, Jason Merrill, John Spicer, Herb Sutter, Bjarne Stroustrup, Alex Stepanov, cùng các thành viên trong ủy ban chuẩn hóa.
🎯 Mục tiêu Học tập
- Xác định và triển khai hàm
main, đồng thời hiểu rõ cách tương tác với hệ điều hành. - Thực hiện biên dịch qua dòng lệnh và quản lý các luồng I/O cơ bản (
cin,cout). - Áp dụng các câu lệnh điều khiển luồng để giải quyết các bài toán logic lặp, ví dụ như đếm số lần xuất hiện.
- Triển khai cấu trúc logic để đếm và xử lý các trường hợp liên tiếp của dữ liệu đầu vào.
- Phân biệt giữa toán tử gán (
=) và toán tử so sánh bằng (==) trong các câu lệnh điều kiện. - Sử dụng đối tượng lớp (
Sales_item), truy cập các hàm thành viên thông qua toán tử dấu chấm, và bao gồm các tệp tiêu đề tùy chỉnh. - Phân biệt các kiểu nguyên thủy khác nhau và dự đoán kết quả của các phép chuyển đổi kiểu và hiện tượng tràn số học không dấu.
- Triển khai các tính năng C++11 bao gồm khởi tạo danh sách,
nullptr,constexpr, và các từ khóa suy diễn kiểu. - Phân biệt giữa khai báo và định nghĩa biến, áp dụng quy tắc phạm vi để quản lý tính hiển thị của tên gọi.
- Phân biệt giữa tham chiếu và con trỏ, và sử dụng
void*để xử lý bộ nhớ một cách tổng quát.
Bài học 共 19 课时 · 预计 57.0h
Bài học
Lesson
This lesson introduces the fundamentals of C++ programming, focusing on the structure of the main function as the mandatory entry point for all applications. Students will learn how to configure their development environment, utilize standard input/output streams, and understand the importance of return values for program execution.
This lesson explores C++ stream-based logic, focusing on how to use input streams as boolean conditions to process data of indeterminate length. Students will learn to implement state-tracking algorithms and understand how user-defined classes can be integrated into stream operations for efficient data handling.
This lesson explores C++ primitive arithmetic types, including integral, floating-point, and void types, while explaining how they map to hardware memory. Students will learn to distinguish between signed and unsigned integers, understand memory representation, and select appropriate data types for specific programming tasks.
This lesson explores the fundamental differences between pointers and references in C++, focusing on how pointers store memory addresses while references act as permanent aliases for existing objects. Students will learn to implement complex data structures, apply const correctness, and utilize type qualifiers like volatile and restrict to ensure memory safety and performance.
This lesson explores efficient C++ namespace management by using declarations to streamline code and avoid repetitive prefixes. It also covers the importance of header guards in separate compilation to prevent redefinition errors and maintain clean, modular project structures.
This lesson explores the use of iterators as a universal mechanism for navigating diverse C++ containers, emphasizing the importance of the begin and end sentinel pattern for generic programming. Students will learn to perform standard iterator operations, understand the risks of iterator invalidation, and recognize why using inequality operators ensures code portability across different data structures.
This lesson explores the fundamental distinction between lvalues, which represent objects with persistent memory identities, and rvalues, which are transient values or literals. Students will learn how to identify these expressions, understand the rules for lvalue-to-rvalue conversions, and apply these concepts to operator precedence and memory management.
This lesson explores the fundamental structure of C++ statements, focusing on the use of expression statements, null statements, and compound blocks. Students will learn how to properly manage scope and avoid common logic errors, such as extraneous semicolons, while applying these concepts to control flow and algorithmic tasks.
This lesson explores the principles of function design, focusing on the distinction between lexical scope and execution lifetime for automatic objects. Students will learn to manage memory efficiently by understanding how parameters, local variables, and static variables behave within a program's stack.
This lesson explores the distinction between automatic and static object lifetimes in C++, explaining how they differ in memory allocation and persistence. You will learn how to manage local state effectively by choosing between stack-based automatic variables and function-scoped static objects.
This lesson explores the transition from structs to Abstract Data Types (ADTs) by implementing class encapsulation, access modifiers, and interface/implementation separation. Students will learn to design robust classes using constructors, nonmember interface functions, and friendship to protect internal state while maintaining functional flexibility.
This lesson explores the transition from passive data structures to Abstract Data Types (ADTs) in C++, emphasizing the role of encapsulation in maintaining internal state. Students will learn how to use classes to separate interfaces from implementation details while managing data integrity through access control and static members.
This lesson explores the C++ stream hierarchy, emphasizing that IO objects must be passed by non-const reference due to their non-copyable nature. It also covers the selection of sequential containers, highlighting the performance trade-offs between structures like vectors and lists based on access patterns and insertion requirements.
This lesson explores the relationship between C++ container size and capacity, emphasizing how memory reallocation affects iterator validity and performance. Students will learn to distinguish between container-specific operations and generic algorithms, while mastering the use of iterators to safely manipulate container contents.
This lesson explores the use of associative containers like std::map and std::set to achieve efficient logarithmic-time lookups, while contrasting ordered and unordered variants. It also covers implementing automated memory management using smart pointers (std::unique_ptr, std::shared_ptr, and std::weak_ptr) to handle shared resources safely.
This lesson explores the mechanics of C++ copy control, focusing on the distinction between initialization and assignment, the risks of synthesized copy operations, and the implementation of custom copy constructors and assignment operators. Students will learn to apply the Rule of Five to ensure robust resource management and prevent common memory errors like shallow copies and double-frees.
This lesson explores the philosophy of operator overloading in C++, focusing on how to implement unary and binary operators to make user-defined types behave like first-class citizens. Students will also learn to construct class hierarchies using inheritance, access control, and virtual functions to enable polymorphic behavior.
This lesson introduces generic programming in C++ by using templates as blueprints to create type-independent functions and classes. You will learn how the compiler performs instantiation to generate concrete code, the importance of minimizing type requirements for reusability, and why template definitions are typically placed in header files.
This lesson explores the use of `std::tuple` as a heterogeneous container for grouping multiple data types in large-scale C++ systems. Students will learn how to initialize, access, and compare tuples while evaluating when to use them versus custom structs for improved code efficiency and readability.