Professional Documents
Culture Documents
Programming
Lab 6 ~ week 11
Polymorphism
Objectives:
suitable operators
A bit of biology :)
Scientists at the University of Cambridge call chameleons "just phenomenal," but say
it's a "myth" that they change color to camouflage themselves. Their skin is covered with
several layers of very special cells called chromatophores that respond to chemicals
from the nervous system and bloodstream. Inside these cells are tiny sacs containing
color and when the signal comes, this color is released and spreads throughout the
chromatophores. They only have four shades to work with -- yellow, red, blue and
brown -- but like artists, chameleons mix colors to produce other colors, like red and
yellow to produce orange….
1. State whether each of the following is true or false. If false, explain why.
virtual functions.
polymorphism
2. Both string and vector define an overloaded == that can be used to compare
objects of those types. Assuming svec1 and svec2 are vectors that hold strings,
expressions:
a. "cobble" == "stone"
b. svec1[0] == svec2[0]
c. svec1 == svec2
d. "svec1[0] == "stone"
3. Copy each of the following code snippets and answer the questions that follow.
Code Snippet A:
Code Snippet B:
members. Members are defined within a class scope. Non-members can either
scope. Consider the following three declarations of the + operator inside the
Download the XYPoint class source on Thuto and for each of the
a. %
c. <<
d. &&
e. ==
f. ()
6. Declare and implement and test the following operators for the XYPoint class.
a. Assignment operator
d. Insertion operator
e. Extraction operator
7. In the previous labs and class exercises, you wrote interfaces and/or
a. Person
b. Matrix
c. Shape
d. MobileContact
e. Time
8. Declare and implement and test at-least three operators for one of the classes
analysed in 6 above.