
CS 201 – The Cold Cold Final
1) Consider the class ‘snow’ above. Assuming each int
is four bytes, how many bytes is a ‘snow’?
a) Four
b) Eight
c) Twelve
d) Some other number.
2) (Yes/No) Does the class ‘sleet’ have a variable named
‘density’?
3) I am using my friend’s ‘string’ class. He tells me that it can store any number of
characters per string, and that it can store any character in each string with no restrictions.
I observe that the string ‘hello’ takes 9 bytes of RAM. I run this test on Tuesday while
it’s snowing outside. I’m using a Mac which I bought because of their Swith™
campaign. My friend is a very nice person but he doesn’t like Monty Python so I’m
thinking about dumping him. He says the string class was easy to write. The string ‘hi’
takes 6 bytes. How is this string class likely implemented?
a) Array of chars with a null byte at the end.
b) Array of chars with a length field.
c) Using a binary tree.
d) As a set of letters.
4) (Yes/No) Is there an example of operator overloading in the line of code below?
cout << “hi”;
5) List every function invoked by the code below. Every variable is of type ‘Snowman’.
A = b+3-c;
6) Assume that s is an ‘ice’ as shown above. Which is correct?
s->temp = 12; s.temp = 12;
7) What type is the following expression? The variable ‘p’ is a pointer to float.
*(p+3)
class sleet: protected snow {
float wetness;
};
class snow: public ice {
protected:
int density;
};
class ice {
public:
int temp;
private:
int thickness;
};