{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

scan0005 - ANSWER KEY Polytechnic Tutoring Center Final...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ANSWER KEY Polytechnic Tutoring Center Final Exam Review - CS 1124, Spring 2009 Disclaimer: This mock exam is only for practice. It was made by tutors in the Polytechnic Tutoring Center and is not representative of the actual exam given by the CS Department. 1. What is the output with the function call emu (6) ? edeededeee 2. What is happening in the code and does an error occur? If so, where would it occur? The error occurs in line 5 where we attempt to dereference a pointer that had its memory released to the system. Since we made a shallow copy in line 2, when we released the memory in line 3 we removed something that was being used by another pointer. Thus causing the error. 3. In the following examples, identify whether each case invokes the assignment operator, copy constructor, or neither, of class MyClass. a) MyClass obj 1 , obj 2; obj 1 = obj 2; Assignment Operator b) MyClass obj l (obj2) ; Copy Constructor 0) MyClass obj 1 = obj 2; Copy Constructor (1) MyClass* objl = new myClass (obj2) ; Copy Constructor e) MyClass* obj 1 = aobjz; Neither 4. Given: class Base {/*code*/}; and class Derived : public Base {/*Code*/}; Consider each question separately and answer YES or NO. a) If Base has Virtual functions then Derived must override them all NO b) Any Virtual fimction in Derived must be virtual in Base NO 0) ~Base should be Virtual YES (1) Any object of type Derived is a object of type Base YES e) Any object of type Base is a object of type Derived NO i) Assigning an object of type Base to Derived is called slicing NO g) By default pure Virtual functions in Base are PV in Derived YES h) By default, the default Derived constructor calls Base default constructor before executing any other code YES i) ~Derived always calls ~Base after its body is executed YES Final Exam Review — Page 1 ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online