A preliminary study guide for the CISC181h final, Fall 2005. (Finalized on Wednesday) (1) First, make sure you understand the programming projects. I may ask some questions about those. (2) Pass by reference, pass by value, "simulated pass by reference" using pointers (C style pass by reference) (3) Functions: formal vs. actual parameters function call, prototype, definition (4) Arrays: know that arrays are always passed by reference the name of the array is a pointer to the 0th element you can put [] in a function prototype or definition, but NOT in a function call, e.g. void sortArray(int array[], int count); // good ... cout << "I'm about to sort" << endl; sortArray(array[], count); // BAD BAD BAD it should be: cout << "I'm about to sort" << endl; sortArray(array, count); // good (5) Pointers: know how to use pointers with regular types such as int as well as with structs and objects of classes i.e. know that (*a).b is equivalent to a->b (6) Unix commands: Know that .. means "parent directory" Know that . means "current directory" Know that * is a wildcard that matches any character Know that ~/ means "MY" home directory but ~jsmith/ means jsmith's home directory Know these commands at least: cp mv ls ls -l rm pwd cd mkdir rmdir chmod mode file chmod -R mode file know the symbolic modes such as a+rx as well as the numeric such as 755 rm -rf foo (dangerous!!! but effective when rmdir says "dir not empty") -r means recursive (remove all files under this directory) -f means "force it"... even if file permissions would deny you access man (7) Know preprocessor vs. compiling phase vs. linking phase "Undefined symbol" errors come from the linker and mean you have a function call with no matching function definition The linker errors refer only to the .o file in which the function call appears, with no line number. (Missing function prototypes give you "undefined" at the compiling phase with a line number) (8) Know how to declare a class definition for a simple class with public member functions and private data members. basic functions constructor setters and getters print function advanced functions copy constructor overloaded = operator destructor remember the ; at the end! (9) Know how to set up a .h file with #ifndef FOO_H #define FOO_H ... #endif (10) Review your binary, decimal, hex, octal http://copland.udel.edu/~pconrad/cisc105/05F/examInfo/E03_practiceQuiz/quiz2.html (11) Makefiles Know how to write a basic makefile to compile a simple program e.g. a main program that uses a class and so has to be linked together with that class's member functions. Know how to interpret the rules in a simple makefile Know how to change the C++ compiler from g++ to CC (12) Know the steps for dealing with a seg fault: unlimit core compile with -g file re-run the program to make a "Segmentation Fault (core dumped)" message dbx a.out core (Use gdb instead of dbx if compiling with g++) (Use ./myprog instead of ./a.out if your binary is called ./myprog) When done, remove the core file, since it will take up lots of disk space. (13) Practice some "what is the output" type of questions.... I'll try to put some up on line by Wednesday for you to practice from. (14) Review sorting... Sorting in ascending (descending) order: for (i = n down to 2) { find the largest (smallest) in 1 elements put that at the end of the array (i.e. in position i - 1 } Remember that if you are sorting parallel arrays, you have to swap both arrays If you are sorting an array of structs, you need to swap all the fields If you are sorting an array of pointers, you can just swap the pointers.