CSC 210 A7
CSC 210 A7
Exercises
a. 39 (Page 883)
b. 1 - 10, 14 - 19 (Pages 965 - 969)
c.
39. Suppose that the definitions of the classes employeeType, fullTimeEmployee, and
partTimeEmployee are as given in Example 12-9 of this chapter. Which of the following
statements is legal? (14)
1. employeeType tempEmp;
Because employeeType is an abstract class, you cannot instantiate an object of this class.
Therefore, this statement is illegal.
b. fullTimeEmployee newEmp();
1.
a. true
b. false
c. true
d. false
e. false
f. false
g. false
h. false
i. true
j. false
k. false
l. true
m. true
The operator overloading function’s name should be the keyword operator followed by the operator to be
overloaded
3.
4. example:
{ return *this;
5.The statement return this; returns the address of the object while the state-
6.function that is non-member of a class but has access to all members (public or non-public) of class
member of a class.
8.
b.
{
int d11=(1000*date1.dyear+100*date1.dMonth + date1.dDay);
intd12==(1000*date2.dyear+100*date2.dMonth + date2.dDay);
if(d11>d12)
{return true;}
else
{ return false;}
9. Because the left operand of << is a stream object, which is not of the type mystery.
10.1
15. In Line 4, the return type of the function operator* should be temp.
16.
17. In Line 3, the return type of the function operator< should be bool.
19. In Lines 3 and 11, the return type of the function operator+ should be discover. Also since operator+ is a friend
function of the class, the name of the class and the scope resolution operator in the heading of the function, in Line
11, are not needed. The correct statements are: