CSC 213 Midterm, Spring 2008

Notre Dame University–Louaize · Program Design and Data Abstraction II · 3 pages

All CSC 213 files
CSC 213 Midterm, Spring 2008, page 1

Stuck on a question? A tutor can walk you through it.

CSC 213 Midterm, Spring 2008, page 2 CSC 213 Midterm, Spring 2008, page 3

More CSC 213 files

Show the text of this exam
1, Write the constructor and the destructor of the dynamic class {4 pts) v- Forthe declaration glve the output Time t(1003,u(40); cout << t+u <<" "“<<int(t+u); vi- Forthe question ¢ above which overloaded function ere called [- cout << teu oaeene Hecoute<Intiteup, 0 He eee nee vii- Trace the main program and give output vold malnd] 4 Tine getup(6,45),lunch!1.6,"pm") ,oclobec: couis<"get up al"s<gatup; coul<<"classes starts at s<getup+90; cout <<lunch at “<<iuneh; cin=>gotobec; = input 22°30 coui <<"go to bed at"<<gatehed <<end|; -----------~..---20---- = Viii- Which function gives @ conversion from integer to Time? ix- Whien function gives a conversion from Timeta lntegar? @-The following is adacleration of the class Scuare (by using comnosition whe the class Resang’s) 116 pts) Rectangle sq: Soliere (double len): dovSle getlenathy: id Satengthidoubis le i, Wthe the Ganette ctor in twe me consttucta") anc us 1 Part 1/33 pts) The cless Co mpactChar stares 2 character along with its repeat count. For instance, the string “...", can be represented by a CompactChar object with character ".” And repeat count 3 times. class CompactChar private: : cher ch; int repeateount; public: CompactChar(cher c, int repeatent), char getchar(; int getrepeatcaunt(); f object that correspond to strings of répeecing ii, Add an overloaded version of the relatio nal operator == as a frieng of the class The operator compares only the chara iil, Acc an owerloaded version of the relational o operatar Gomperes the repeatco ame funeton tat es L iv. As a friend, declare an overload tmatehireseateour For example from the The following 1s@ declaration ofa co n CompastChar obigel 2nd canes it to a string < asa friend af the class. The ifyou have time do the ute re; operatcr § ‘CampaciC:, srod’*.":3 6 String &§: Goad Luck