CIS 250 (C++ II) Demonstration Programs
Input, Output, File I/O
- cinfunc.cpp: some basic istream functions
- manips.cpp: output formatting using stream manipulators
- fileio1.cpp: simple text file I/O
- fileio2.cpp: binary file I/O
- fileio3.cpp: random access file I/O
Passing by reference
- demoref.cpp: demonstration of reference variable
- demobyref.cpp: demonstration of old way of passing references using pointers
Classes and structs
- demostruct1.cpp: demonstration of struct usage
- demostruct2.cpp: nested structs and an array of structs
- Point.cpp: simple class demonstration
- democlass1.cpp: demonstration of class usage
- democlass2.cpp: using header files with classes
- Demonstration of many class techniques including dynamic memory allocation
- Updated person class including operator overloading, friend functions, and a copy constructor
- polytest.cpp: demonstration of inheritance, polymorphism, and virtual functions
Sorting
- sort.cpp: various sorting algorithms
Array, vector, stack, queue, deque
- array1.cpp: declaring and passing arrays to functions
- array2.cpp: arrays and pointer arithmetic
- array3.cpp: multidimensional arrays, array initialization
- array4.cpp: multidimensional arrays and pointer usage
- array5.cpp: arrays of strings
- array6.cpp: sorting arrays
- testVect.cpp: the vector class demonstration program demonstrated during lecture
- TestContainers.cpp: demonstration of deque, stack, and map containers
Variable and default arguments, overloading functions and operators, templating
- overload1.cpp: overloading functions
- testVar.cpp: variable argument demonstration
- default1.cpp: default function arguments
- Demonstration of operator overloading
- template1.cpp: function templating
Enumerations, namespaces
- testEnum.cpp: enumeration demonstration
- Demonstration of namespaces
Data structures
- Linked list demonstration
- Templating linked lists
- MyObj.h: simple class used for filling tlist
- tlist.h: implementation of templated linked list class using dynamic memory allocation
- TestTList.cpp: test driver for tlist.h
- gll.h: implementation of templated linked list class using reference variables
- testgll.cpp: test driver for gll.h
- Stack:
stack.h
TestStack1.cpp
- Stack with templating (stack size set at instantiation):
stackt.h
TestStack2.cpp
Note: This class creates an array to hold the stack.
- Stack with dynamic allocation (stack can grow and shrink) and templating:
stackd.h
TestStack3.cpp
- Queue with dynamic allocation and templating:
queued.h
TestQueue3.cpp
Recursion
- recurse.cpp: demo of recursive functions
- recursion.cpp: more complete demonstration of recursive functions
- Fibonacci2.cpp: more generalized recursive Fibonacci program
- RecursiveLargest.cpp: finds the largest array element recursively
Miscellaneous
- testToken.cpp: string tokenization demo