20-CS-122-001 Computer Science II Spring 2012
struct and class

Virtual functions, classes, inheritance, lists, queues, stacks, applications

Simple struct Simple illustration of a struct
Pointer to object Same struct as above, use pointer to object
Private elements Show how to access private elements of a struct object
Operator = The = operator for structs is not overloaded (see power point demo)
Simple class Simple class that looks and behaves like a struct
Constructor Constructor is added to initialize an object's variables
Method A simple method is added
Private data Data members private, constructor only way to assign values
Peculiarity of C++ A peculiarity of C++ is that one can peek at the values anyway
Pointer variables Simple class with pointer variable, inited by constructor
Destructor Destructor required and triggered by delete call
Destructor Destructor triggered by return from function where created
First class Reasonable first class: a data element and simple methods
Split prototype Same as above but split prototype and variables from methods
Second class Reasonable second class: copy constructor, allocates memory for object
Copy constructor Focus on copy constructor
Split prototypes Like basic1.cc but split prototypes and variables from methods
Another class A simple class, more methods than above
Listable class A reasonable candidate for objects maintained in a list
Use of above in lists Add to above Cell and Linked List - use friend
Again Same as above except list object is not referenced
Tail pointer Same as above except list uses a tail pointer
Many types in list Shows that objects of different classes can easily be put into a List
Again Same as above except "l" is an object of class "List"
Remove from list Do some removing of objects
Adaptable list Use constructor to bring in the "disp" and "find" functions
Overloaded operators Overload list operators (see list.0_1.h and list.0_1.cc)
BigInteger class List of biginteger objects
BigInteger class Same as above except "l" is an object of class "List"
BigInteger class Use BigInteger class to help with the functions (first attempt)
BigInteger class Overloading the "*" operator for BigInteger class (see bigint.1.cc)
Doubly Linked List Use a doubly linked list (see list.2.h and list.2.cc)
Doubly Linked List Use a doubly linked list (see list.3.h and list.3.cc)
Complex class Overload = operator plus complicated data type
Fraction class Fraction class (see power point gcd demo)
Fraction class Slight changes to the above
Fraction class Heavy operator overloading
Date class A date class
Param Pass Example of parameter passing (see power point demo)
bigint.cc Arbitrarily large integers
bigint.h Include file for above
bigint.1.cc Arbitrarily large integers
bigint.1.h Include file for above
biginttest.cc Test the above
list.cc Maintain lists of objects, basic list ops (see power point queue and list demos)
list.h Include file for above
list.0.cc Maintain lists of objects, uses "disp" and "find" pointers to functions
list.0.h Include file for above
list.1.cc Maintain lists of objects, basic, uses tail pointer for quick insertion
list.1.h Include file for above
list.2.cc Maintain lists of objects, advanced, uses tail pointer
list.2.h Include file for above
list.3.cc Maintain lists of objects
list.3.h Include file for above
list.0_1.cc Maintain lists of objects, heavy operator overloading
list.0_1.h Include file for above
Makefile Makefile for all code on this page
Power Point
Operator = The = operator for structs is not overloaded
Param pass Illustration of passing parameters, copy constructors
List Describes the List abstraction
Queue Describes the Queue abstraction
GCD Describes the greatest common divisor algorithm