- What TYPE is the following
expression?
"hello
world"
- What TYPE is the following
expression?
new Rhino();
-
What
TYPE is the following expression? Assume an Rhino is declared as shown
below.
*(r->next->next);
Rhino *r = new Rhino();
Rhino: public Animal {
int age;
bool gender;
Rhino *next;
}
- I have an unordered linked
list with 1,000 items. I wish to search for the occurance of
a specific item known to be on the list. How many items on
average must I inspect.
- Given the sizes below, how
many bytes are needed to store a linked list of 1000 doubles.
sizeof(double) = 8; sizeof(float) = 4; sizeof(any
pointer) = 4; sizeof(int) = 4; cizeof(char) = 1;
- What happens when I run this
code?
char *ptr = new char[10];
cout << "Length is " << strlen(ptr)
<< endl;
-
CS 201 – A
Blast of a Midterm
What
does the code below do?
int herd = 1; int *h = &herd; int size = 2; int *d =
&size;
herd = 12;
*d
= 17;
cout << size;
- Does a normal operator* on
an object call new?
yes, normal
no, not normally
- Which takes less room to
store, a C style string (char * with null byte) or a Pascal style
string?
- Which of these lines calls a
constructor?
r = new Rhino();
Rhino r;
- Here are two functions.
Which is likely faster?
print(Rhino r) { cout << r.age
<< endl; }
print(Rhino &r) { cout <<
r.age << endl; }
- In the question above, which
function calls the constructor?
-
CS 201 – A
Blast of a Midterm
Tell
me something that a linked list is
better at than an array, and something a linked list is worse at.
LL
is better because:
_________________________________________________________________
Linked
list is worse
because:
________________________________________________________________
-
When does a class
likely
need an operator=()?
-
The
class ‘Group’ in http://euclid.nmu.edu/~randy/Classes/CS201/Tests/Final2001/Group.cpp.
Fix it.
- When
are destructors for a class called?
- Write
me a program that prints the value of the 100th byte of it's EXECUTABLE.
- Change the program at
http://euclid.nmu.edu/~randy/Classes/CS201/range.cc such that it
compiles and runs.
- Change the program at
http://euclid.nmu.edu/~randy/Classes/CS201/range.cc such that the class
'Range' is template-ized.