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.
inline
, virtual
, virtual functions,
: public
const
methods
delete
override
delete
= 0
const&
template
functions, type parameters, consistency of types
list
, vector
.begin
, .end
map
, stack
<algorithm>
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?
Code snippets related to these are available.