The exam is closed-note, closed-book. If you need to know the name of a method (other than .begin, .end) in the STL, I will give that name to you.
#include, #ifndef magic
virtual, virtual functions,
: public
const methods
delete
override
delete
= 0
const&
#includes
template functions, type parameters, consistency of types
.h files
typedef to simplify declaring containers
list, vector, []
vs .at for vector
.begin, .end
map, stack
<algorithm>: have a general idea of what it contains
doit
if doit reads files p and q
and generates r
Note that captures a note (a string) and timestamp
(milliseconds since 00:00 on Jan. 1 1970). It should have a message to
return the note text and a print() method that writes a
formatted date followed by a newline followed by the note text and
another newline. Assume the library function void prDate(int
ms); does the appropriate formatting (but don't write this
function). The constructor for the class should set both attributes.
NoteBook that contains an arbitrary-sized
collection of pointers to Note objects with a constructor
that sets the collection to be empty, an add method that
takes a pointer to a Note and adds it to the collection, and
a print method that prints all notes. You can use the STL in
your answer.
class Node {
Node *nextNode;
ItemType _item;
public:
Node(ItemType item, Node *next = nullptr) : nextNode(next), _item(item) { }
ItemType item() const { return _item; }
Node* next() { return nextNode; }
};
Note your template type parameter should be
named ItemType so you do not have to rewrite this class
in your solution. Note you will need a pointer to the front of the
list and the back of the list; new items will be added to the back
(by a method add), old items removed from the front (by
a method take). Include a method empty
that returns true if the Queue has no items.
Queue.
Queue by value?
That is, what would be the impact of the code
void pr(Queue<string> todo) {
while ( !todo.empty() }
cout << todo.take() << endl;
}
pr to
void pr(const Queue<string> &todo);
fix this?
Node's to
the heap.
list<string>
parameter and returns a new list with every other item. The
function should run in O(n) time.
A and a subclass B, both with
virtual methods xyz, and draw their vtables. Add a
virtual method uvw for B and a virtual
method abc for A, and add these to the vtables.
inline code be in header files?
char s[5];
strcpy(s, "abc"); printf("%s", s);
strcpy(s, "crush"); printf("%s", s);
strcpy(s, "abc"); strcpy(&s[1], "def"); printf("%s", s);
strcpy(s, "abc"); strcat(s, "x"); printf("%s", s);
strcpy(s, "ab"); strcat(s, s); printf("%s", s);
strcpy(s, "abc"); printf("%d", strcmp("abc", s));
strcpy(s, "abc"); printf("%d", strcmp("def", s));
For answers, see the exam 2 review solution link at the bottom of this
page.
Code snippets related to these are available.