EE 221 Sample Programs
Note: examples have been being added and improved
after the recorded course took place based on the more recent course
teachings.
-
Self review of the introductory programing course material
-
Quick C++ review, Introduction
You should be able to follow all of these examples using your knowledge from the first programming course.
-
Introduction to data types
-
Data types: arrays
- Introduction to 1D arrays (some review, some new features)
- Passing by pointer (C) versus passing by reference (C++)
- Dynamic 1D arrays
- Dynamic 2D arrays
- Fill a 2D array with numbers according to a pattern (make good exercises that promote desired skills)
- Investigating index out of range problems (compile and test each example both in "Debug" and "Release" modes)
- Comparion of ways to handle data in 1D and 2D arrays (how do they differ?)
-
Data types: structures
-
Classes
- A very simple multifile project and the idea of libraries
- Timer class - introduction to object oriented programming
- first class Time - basics, private/public data, constructors, accessing and mutating data:
- second class Time - private methods, more functionality:
- third class Time - adding const modifier:
- fourth class Time - friend functions, overloading operators:
- fifth class Time - static, volatile and advanced concepts:
- More OOP Desing Examples, some with embedded system flavor
- Yet another Timer with more operators (optional, not elaborate and more "CS flavor")
- Various state machines (you may want to compare with VHDL code in EE201 or EE311)
- PIXel class (with a little too heavy stress on use of operators)
- Sample OOP Desing vs. plain arrays and functions
(may be too advanced for now. If so, then return to
this example close to the end of the semester)
Task: count occurences of character pairs
- Partially defined class Rational (optional)
-
String class - problem solving with strings, string implementation
-
Files and streams
-
Lists, array based lists and pointer based lists
- Fixed-size array-based Lists
- Dynamic array-based Lists
- Dynamic array-based Lists - assignment operator variations
- Testing constructor and destructor behavior
Run the exmaples below, and then remove copy constructor and/or assignment operator and run them again:
- Dynamic pointer-based Lists (optional for now, we will return here from chapter 11)
-
Stacks
- The simple textbook Stack and an example of application
- Three simple Stacks and the same example
- A Stack of class-objects and the same example
- Stack of a dynamic size and a simple but thorough testing program
- Sample use - MAZE program (analyzing and modification assigned as homework assignment)
- Stack based on linked list and a simple but thorough testing program (optional for now, we will return here from chapter 11)
-
Queues
- The simple textbook circular Queue with static array
- A simple efficient circular Queue with static array
- Queue based on linked list and a thorough testing program (optional for now, we will return here from chapter 11)
- Problem solving with Stacks and Queues (old exam questions)
-
Templates, Standard Containers and Generic Algorithms
- Function overloading case study
- How to create a function template - absolute value case study
- More template examples
- Templates and arrays
- Non-obvious template examples
- Class tempates - Stack example
- Class tempates - Additional Stack examples (optional)
- stack<T>, queue<T> and string as as class templates - no need for new examples, vector<T> - will look at how to use it
- Class tempates - simplified Vector example (no insert or erase functionality)
- vector<T>
- vector<T> 2D
- Introduction to vector<T> and iterators (iterators discussed much further in chapter 11)
- Disable harmless truncated debug info warnings (for old Visual Studio 6)
- Peek quickly into some more STL containers
- Examples of STL use from other EE course (optional)
-
Algorithms (10.5 and notes) and their Complexity (10.4)
-
Linked List - Full Functionality Doubly-linked Linked List like one introduced in Chapter 6.4-5
and fully described in Chapter 11.3
- Linked lists discussed in earlier chapters of the textbook
- Dynamic pointer-based Lists from chapter 6
- Stack based on linked list from chapter 7
- Queue based on linked list from chapter 8
- A simplified bidirectional linked list (in template notation) - see Chapters 6.4 and then 11.3
- An example of sorted unique binary tree concept (in template notation)
-
Searching (only 12.1) and Sorting (only 13.1 and 13.3)
-
Inheritance
- The idea of inheritance
- Virtual inheritance
- Bounded stack - inheritance
- Bounded stack (non-template class based on non-template class)
- Class template based on class template
- Class template based on dynamic class template
- Non-template class based on dynamic class template
- Class template based on STL class template (textbook version)
- Bounded stack - adaptor
- Non-template class adaptor to STL class template
- Class template adaptor to STL class template
- Debug stack (non-template based on template parent)
- Two modified list examples
- Testing constructors, destructor and assignment operator behavior in inherited classes
Source code listings were prepared using Code2HTML, courtesy of Peter Palfrader.