name: first ________________ last _____________________ section number: ________ CS 13001 "Computer Science I" FINAL EXAM The number of points for each question is given in square brackets. 1. [15] Differentiate object-oriented and procedural programming. Describe the benefits of using object oriented programming for code maintenance and development. Differentiate between public and private member functions. Explain why this feature is introduced. For the class definition below, add one private member variable and one public member function that accesses the variable. class myclass{ public: private: }; 2. [10] Define pointer and explain its purpose. Given the following code, explain what each line does and what the last line outputs int *p, a[10], i=5; p=&i; ++(*p); a[0]=*p; p=a; cout << p[0]; 3. [15] The following class definition uses a pointer attribute to store a dynamically allocated array class myclass{ public; myclass(int s){size=s; a=new int[size];} private: int size; int *a; }; Explain the purpose for overloaded assignment. For the above class, write the prototype and an outside definition of the overloaded assignment that protects against self-assignment and permits stackability. 4. [10] Differentiate between vectors and (raw) arrays. Explain what iterator is. Given the following vector definition vector v; Write code that uses an interator to insert an element into this vector and removes an element from this vector. 5. [10] Given this code inside main() function definition const int SIZE=100; int a[SIZE][SIZE]; give a definition of a function that accepts this array as a parameter, finds the maximum element in this array and returns this maximum element as a return value of the function. 6. [10] Define recursion. Give an example recursive function definition. Compare recursion with iteration. Rewrite your recursive solution with iteration. 7. [10] Describe the need for namespaces. Define three styles of employing (using) names from a namespace. List these styles relative advantages and disadvantages. Explain why importing all the names from a namespace in a header file is considered bad style. 8. [10] Explain the need fro UML diagrams in programming. Differentiate between class and object diagrams. Give examples of use-case and interaction(flow) diagrams. 9. [10] Motivate (explain the need for) automatic code documentation system like Doxygen. Give an example of Doxygen short (one line) and long (multi-line) comment and explain what they are for.