--- Open Books --- (請依序作答) 10% I. Briefly answeer the following questioons: (a) 解釋 constructor, copy constructor (b) 解釋 destructor (c) 解釋 overloading 10% II. 舉一C++程式為例說明 data hiding (information hiding)的觀念. 要說明 private, protected, public 等屬性的用處 以及 friend 有何用? 10% III. 考慮 C++程式, 若A是一個 class, 且已寫過 A bb; 則 (a) A aa= bb; 到底做何事? (b) 和 A aa; aa=bb; 有何不同? (考慮它們叫用的 function) (c) 那寫 A aa(bb); 呢? 10% IV. Write the makefile for the following example: The makefile will generate only one executable file "myprog". (assume the link command is: g++ -o myprog aa.o bb.o cc.o dd.o) The command "make clear" will clear all obj (*.o) files. And "make clobber" will remove the executable file and all obj files. The program consists of 4 ".c" files and 5 ".h" files: (1) ac.h --- included in aa.c, cc.c (2) b.h --- included in bb.c (3) bc.h --- included in bb.c, cc.c (4) bcd.h --- included in bb.c, cc.c, dd.c (5) cd.h --- included in cc.c, dd.c 20% V. Consider the following C++ program: #include class A{ public: virtual void talk(){ cout << "a"; } }; class DOG: public A{ public: void talk(){ cout << "h"; } }; class CAT: public A{ public: void talk(){ cout << "e"; } }; int main(){ A * px[7]; DOG * ppp; ppp = (DOG *)new A(); ppp -> talk(); ppp = (DOG *)new DOG; ppp -> talk(); ppp = (DOG *)new CAT; ppp -> talk(); cout << "\n--..---" << endl; px[0] = px[2] = new DOG(); px[1] = px[3] = new A(); px[4] = new DOG(); px[5] = px[6] = new CAT(); for(int k=0; k<= 6; k++){ px[k] -> talk(); } cout << "\n==..===" << endl; } (a)What would be the output of the above C++ program? (b)If we remove the word "virtual" in class A, what is the output of this program? (c)這程式在說明 C++ 的什麼觀念? 10% VI. Write a C++ program that will append your name(in English) and phone number to the text file "classmate.dat". (加入一 line, 你的 name 和 phone number 間空一格) 10% VII. Describe how a STACK can be implemented as a linked list. Diagram the PUSH and POP operation for the linked-list implementation. (不用寫出程式) 20% VIII. Design and Implement a template class for QUEUE using an array. (寫成 C++ 的 class) (內部設計成 circular queue. 要包括 isempty(), isfull()等functions)