{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Thorndale};}{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}
{\f28\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Thorndale};}{\f29\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Thorndale};}{\f31\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Thorndale};}
{\f32\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Thorndale};}{\f33\froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Thorndale};}{\f34\froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Thorndale};}
{\f35\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Thorndale};}{\f44\fmodern\fcharset238\fprq1 Courier New CE;}{\f45\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f47\fmodern\fcharset161\fprq1 Courier New Greek;}
{\f48\fmodern\fcharset162\fprq1 Courier New Tur;}{\f49\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f50\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f51\fmodern\fcharset186\fprq1 Courier New Baltic;}}{\colortbl;\red0\green0\blue0;
\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;
\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 \fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \snext0 Normal;}{
\s1\ql \li0\ri0\sb240\sa60\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\fs28\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext15 heading 1;}{\s2\ql \li0\ri0\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\b\fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon0 \snext0 heading 2;}{\*\cs10 \additive Default Paragraph Font;}{\s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 
\snext15 Default;}{\s16\ql \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext16 Text body;}{\s17\ql \fi-283\li567\ri0\sa120\nowidctlpar
\tx567\aspalpha\faauto\rin0\lin567\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon16 \snext17 Hanging indent;}{\s18\ql \li0\ri0\sb240\sa120\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs28\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext16 Heading;}{\s19\ql \fi-360\li360\ri0\nowidctlpar\aspalpha\faauto\rin0\lin360\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext19 List;}{
\s20\ql \fi-360\li720\ri0\nowidctlpar\aspalpha\faauto\rin0\lin720\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext20 List 2;}{\s21\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext21 header;}{\s22\ql \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon16 \snext22 Table Contents;}{
\s23\qc \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\i\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon22 \snext23 Table Heading;}{\s24\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext24 Index;}{\s25\qc \li0\ri0\sb240\sa60\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\fs32\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext26 Title;}{
\s26\qc \li0\ri0\sa60\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext16 Subtitle;}{\s27\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext27 footer;}{\s28\ql \li0\ri0\sb120\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \i\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \sbasedon15 \snext28 caption;}{\*
\cs29 \additive \cf1\lang0\langfe255\langfenp255 Numbering Symbols;}{\*\cs30 \additive \cf1\lang0\langfe255\langfenp255 WW-Default Paragraph Font;}{\*\cs31 \additive \cf1\lang0\langfe255\langfenp255 \sbasedon30 page number;}}{\info{\author CNRS}
{\operator CNRS}{\creatim\yr2003\mo8\dy29\hr23\min17}{\revtim\yr2003\mo12\dy12\hr10\min55}{\printim\yr2003\mo11\dy14\hr13\min4}{\version5}{\edmins1}{\nofpages2}{\nofwords612}{\nofchars3493}{\*\company CNRS-HSU}{\nofcharsws4289}{\vern8269}}
\margl1440\margr1440\margt1400\margb720 \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale100\nolnhtadjtbl 
\fet0\sectd \sbknone\linex0\headery709\sectdefaultcl {\header \pard\plain \s21\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 \fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\fs16 CS 131 - Homework #13\tab \tab p. }
{\field{\*\fldinst {\fs16 \\page}}{\fldrslt {\fs16\lang1024\langfe1024\noproof 2}}}{
\par }{\fs16 Fall 2003
\par }}{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}
{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8
\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s15\qc \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs20\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\b CS 131 - Intro to Computer Science I - Fall 2003
\par LAB #13 Exercise 
\par 
\par lab #13 exercise due: Friday, December 12th, END of lab
\par }\pard \s15\qc \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b 
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b\ul LAB #13 EXERCISE}{\b 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\b 
\par }{Consider the following files, available from the course web page's "Homeworks and Handouts" link along with this handout:
\par }{\b 
\par Student.h, Student.cpp}{: these declare and implement a class }{\b Student}{, remarkably similar to Student2.h and Student2.cpp declared and defined for the Week 14-2 lecture, except that it now also includes an overloaded }{\b == }{
operator. It also includes explicitly-defined copy constructor, destructor, and overloaded assignment (=) operators.}{\b 
\par 
\par Prof.h}{, }{\b Prof.cpp}{: these declare and implement a class }{\b Prof}{, remarkably similar to Prof from Homework #7, except that it now includes a no-argument constructor, includes an overloaded ==, and has had all floats changed to doubles. }{\b 

\par 
\par Course.h}{, }{\b Course.cpp}{: these declare and implement a class }{\b Course}{. A course has
 a number (such as "CS 131"), a name (such as "Intro to CS"), a number of students enrolled, a dynamic array of those Student's enrolled,  and an instructor (a Prof instance).  Note the following implementation details:}{\b 
\par 
\par }\pard \s15\ql \fi-405\li825\ri0\nowidctlpar\aspalpha\faauto\rin0\lin825\itap0 {*\tab in this world, no class can ever 
exceed 30 students. A named constant, ENROLLMENT_MAX, is used for this (in case this world changes its mind about what the max should be later...)
\par 
\par *\tab when the first student actually enrolls in a class, at that point a dynamic array of Students of size ENROLLMENT_MAX is created/
\par 
\par *\tab what keeps the program from thinking that every class with at least 1 student has ENROLLMENT_MAX students? The numEnrolled member variable: the class is careful to ONLY consider array elements from 0 to (numEnrolled-1) to be enrol
led Students,  and numEnrolled is only changed as students enroll or are removed from the course.
\par 
\par *\tab read the code to see what member functions it includes...
\par }{\b 
\par }\pard \s15\ql \li-15\ri0\nowidctlpar\aspalpha\faauto\rin0\lin-15\itap0 {\b test_Course.cpp}{
: some quick'n'sleazy (and incomplete!) tests of class Course; they DO show the effect of NOT having an explicit and appropriate = operator when a class has pointers or dynamic member variables.}{\b 
\par }\pard \s15\ql \fi-405\li825\ri0\nowidctlpar\aspalpha\faauto\rin0\lin825\itap0 {
\par }\pard \s15\ql \fi-420\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\b 0.\tab }{For your convenience, I've created copies of the above files in }{\b ~st10/131lab13_public}{, also, for quicker copying into your working directory:
\par }{\b 
\par }{\tab }{\af2 cp ~st10/131lab13_public/*  .}{
\par }{\loch\af2 
\par \hich\af0\dbch\af0\loch\f2                                 }{^}{\loch\af2 
\par }{                                                                              |       remember, the dot is important! That's a nickname for
\par \tab \tab \tab \tab \tab \tab               your current working directory...
\par }{\b 
\par 1.\tab }{If you try to compile}{\b  Course.cpp}{ and  }{\b test_Course.cpp}{, you will see that they fail --- there are redefinition errors, because #include'd Course.h also #include's Student.h and Prof.h. But you know how to }{\b fix}{
 this, now: go into }{\b Student.h}{, }{\b Course.h}{, and }{\b Prof.h}{ and add those lovely }{\b #ifndef}{'s as discussed in lecture.}{\b 
\par 
\par }{\tab }{\b Recompile}{ Student.cpp, Course.cpp, and Prof.cpp, and now, }{\b recompile}{ test_Course.cpp. It should now work, and you should be able to execute }{\b test_Course}{
 and see its results, including the sad effect of its not having an explictly- and appropriately-designed = operator.
\par 
\par Add your name to the }{\b Next: }{list on the board, so that I can verify that }{\b test_Course }{indeed now can be run. (While you are waiting, it should be safe for you to proceed with #2...)
\par 
\par }{\b 2.\tab }{Now, modify }{\b Course.h}{ and }{\b Course.cpp}{ to add explictly- and appropriately-defined copy constructor, destructor, and overloaded = operator.  (Note: it is probably wise to ch
eck if enrolled is NULL, and act accordingly if so, for the copy constructor and = operator. And, for the = operator, what should you do if you are assigning to an existing Course instance with a non-NULL enrolled member variable?)
\par 
\par \tab When done, recompile }{\b Course.cpp}{ and at least re-link }{\b test_Course.cpp}{; you should now see that the copy assigned using = is now properly independent of what it was assigned from.
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\b 
\par }{When you are done, add your name to the}{\b  Next:}{ list on the board. When it is your turn, I will check your }{\b test_Course }{run results and will scan  your copy constructor, destructor, and overloaded =.}{\b 
\par }{
\par }{If, before the end of lab, your test_Course verifies that = produces an appropriate independent copy, and if the quick scan shows that your other modifications look reasonable, then you have successfully completed this lab exercise.
\par }{\b 
\par }{\b\ul 
\par }}