
Learn how POD data classes, or pods, use structs with members like make, year, wheels, and is running; access via the dot operator and understand memory layout and C compatibility.
Explore unions in C++, view memory blocks as multiple interpretations, and learn their role in low level marshalling, packing bit fields, and type checking limitations.
Explore how methods in structs implement encapsulation by binding data with functions, using member functions to modify state and apply information hiding in C++ classes.
Explore access controls in C++ by encapsulating class members with private data and public methods, illustrated with a year example using set and get functions to enforce valid values.
Explore class versus struct in C++, note private by default, and implement a clock with set and get year using a ternary operator to enforce 2019.
Constructors are special methods with no return type, named like the class, that initialize a year parameter and default to 2019 when input is invalid, with exceptions next.
Learn how destructors in C++ clean up objects before destruction, usually invoked by the compiler, and how to declare one with a tilde, releasing resources such as file handles.
Explore how to initialize variables in C++, from assignment and function-style calls to constructors and new with initializer lists, including built-in and custom types and arrays.
Explore how C++ pointers enable direct memory access and potential performance gains, and learn to declare, initialize, and use them with address and dereference operations on the stack and heap.
Explore pointers and references in c++, learn how to obtain object addresses and assign pointers. Understand the address-of operator, void pointers, byte pointers, and the auto keyword.
Demonstrate the dereference and address-of unary operators in c++, explaining how the reference operator accesses the object pointed to by a pointer, with code examples and notes on left-side assignment.
Explore how pointers and arrays relate in C++, showing array decay to pointers, printing elements, and passing arrays with their length using a for loop.
Learn safe pointer usage in C++, obtain pointers via the end operator or OS calls, and initialize to null with non-null checks to prevent memory access violations.
Master pointer arithmetic in C++ to access and modify memory through typed pointers, see how increments depend on type size, and compare pointer versus array semantics.
Discover how arrays can go out of bounds with pointer arithmetic and zero-based indexing, risking memory corruption, and learn safe practices for deallocating pointers and avoiding raw pointers.
Contrast typed pointers and void pointers; void pointers need a cast to access memory. Explain const versus constant pointers and how malloc yields void pointers for memory allocation.
Allocate memory with the new operator to the free store and release it with delete, which calls the destructor for custom types and initializes builtin types to zero.
Allocate arrays with the new operator and initialize after allocation. Access elements via pointer arithmetic or array indexing, and delete with the proper array delete.
Memory allocated with new remains valid until you delete it, and careless pointer copies can leave memory inaccessible; use raii with smart pointers and destructors to manage resources automatically.
Explore the C++ STL array and vector, their random access and contiguous memory, with safe range checks via at() and begin end range loops for memory buffers.
Explore C++ references, safer and more convenient than pointers, declared with an ampersand and used like a type, including a getter/setter based year example.
Explore how pointers offer flexibility at a safety cost, and why references cannot be reseated. The example initializes an integer and a reference, assigns a new value, and prints results.
Explore how C++11 introduces the auto keyword for type deduction, declare vectors of tuples with make_tuple, and iterate with a for loop using get for access.
Learn how the range-based for loop in C++11 simplifies iterating standard containers without explicit iterators, using begin and end, with vector initialization and at() access.
Explore how pointers power dynamic data structures using a linked list as a queue in C++. Practice struct and class concepts, pointer access, and memory management with new and delete.
Implement a C++ linked list of tasks using a queue function to allocate and link nodes via p next, access the list from the head, and note potential memory leaks.
Iterate through a linked list by following the next pointers, fix the head pointer, implement a remove-at-head function returning a bool, and add a destroy list routine.
Iterate a linked list using a next pointer, implementing execute task to print each description and return the next task, then run execute all to traverse and destroy the list.
Define and call C++ functions with fixed or variable parameters, explore templates, prototypes, and linking to libraries via headers and linkers.
Explore compile-time evaluation with a const expression, inline hints, trailing or auto deduced return types, and the noreturn attribute for nonreturning functions.
Explain function naming rules: begin with a letter or underscore, avoid spaces or punctuation, and cover overloading, operator overloading, default and variable arguments, and noexcept in C++11.
Learn how to define C++ functions with return types, names, and bodies; pass parameters by value or reference, use const, pointers, and temporaries, and understand overload resolution and struct interactions.
Explain default parameter values in a log message function with a string message and a bool clear_screen defaulting to false. Show how calling without the second parameter uses the default.
Explore c++11 initializer lists, where brace syntax creates initializer_list objects to initialize containers (such as vector), and sum values with a range for loop using begin and end.
Learn variadic functions in C, using ellipses and va_start/va_end to sum stack arguments until minus one, while noting type unsafe risks of va_arg and the need for a first parameter.
Explore function calls, stack frames, parameters, and return addresses, and how inline, calling conventions, extern C, and name mangling enable shared library interoperability.
Learn how to write a basic C++ program with a main function, compile it with g++ to produce a.out on Unix-like systems or a.x on Windows, and run it.
Create a random card generator in C++ using an enum for suits and ranks to model a 52-card deck, with a rand-based selection.
Develop the main function to seed the system clock, generate random cards using static_cast to map integers to card enums, and print the chosen card with cout.
Learn to design C++ classes with encapsulation, abstraction, and information hiding using public, protected, and private access; implement constructors and an animal example to manage private data.
Add a virtual method named make sound in the animal class and override it in the dog class to return woof woof, illustrating the adt example.
Learn to control all copy operations in an abstract data type to avoid dynamic memory aliasing, using copy assignment operator overloading in the dog class.
Explore class templates in C++ by building a generic animal class with dog and cat implementations. See the outputs, like Labrador woof woof and cat moo moo.
Explore the standard template library in c++, focusing on algorithms, containers, iterators, and functions. Learn how sorting and searching work, how vectors resize automatically, and how functors enable function objects.
Analyze time and complexity using asymptotic analysis, count instructions for simple and nested loops, and compare linear and quadratic growth in complexity notation.
Develop and analyze a search function that iterates through an array to find a target, returning its index or -1 and comparing worst, average, and best case time complexities.
Explore implementing a recursive factorial function and compare its complexity to an iterative approach, using a base case and recursive call, and preview amortized analysis in the next lecture.
Create a C++ function with nested loops over arrays to compute a total, then apply amortized analysis to show time complexity as n times m, introducing C++ data types.
Welcome to our CS104, C105 Masterclass! In this class, we will dive into the world of Data Structures and Object-Oriented Programming (OOP) using the popular programming language, C++.
Data structures are an essential part of computer science, as they provide an organized way of storing and manipulating data. By using data structures, we can access and modify data more efficiently, which is essential for developing efficient and effective software.
In our class, we will cover various data structures, including arrays, linked lists, stacks, queues, and trees. We will explore how to implement these structures in C++ and how to perform basic operations like insertion, deletion, and searching. Additionally, we will discuss the advantages and disadvantages of each data structure and when to use them in different situations.
Linked lists, for example, are a popular data structure used to store and manage data in a sequence. Linked lists are efficient because they can be dynamically allocated and are flexible in size. However, they can be more complicated to implement and use than other data structures like arrays.
Stacks and queues are also important data structures that are commonly used in software development. Stacks use the "last in, first out" (LIFO) principle, while queues use the "first in, first out" (FIFO) principle. These data structures are useful for managing data in a specific order, and we will learn how to implement and use them in our class.
Trees are another popular data structure that we will cover in our class. Trees are useful for organizing data in a hierarchical structure and are often used in computer science applications like file systems, databases, and search engines.
In addition to data structures, we will also cover the basics of OOP in C++. Object-oriented programming focuses on encapsulation, inheritance, and polymorphism. With OOP, we can create reusable code, improve code organization and structure, and make code maintenance more manageable.
In our class, we will cover the basics of OOP in C++, including classes, objects, constructors, and destructors. We will also discuss inheritance, polymorphism, and encapsulation, and how they can be used to improve the functionality of our programs.
C++ is a powerful programming language known for its speed and efficiency. It is widely used in developing operating systems, embedded systems, and gaming applications. With C++, we can take advantage of its powerful features to create complex programs with high performance.
In our class, we will explore the C++ syntax and how it can be used to implement data structures and OOP concepts. We will also learn how to optimize our code for performance and efficiency.
To wrap it up, our CS104, C105 Masterclass will provide you with a solid foundation in Data Structures and Object-Oriented Programming with C++. You will learn how to implement data structures, use OOP concepts to improve your code, and take advantage of the powerful features of C++.