// default size of queue array
const int DefaultSize = 100;
// a queue of ints
class queue {
protected:
int *q; // array of queue elements
int size; // number of elements queue can hold
int front; // current position of front element
int back; // current position of back element
public:
// dynamically allocate the array
// and initialize front, back, size
Queue(int sz = DefaultSize);
~Queue(); // deallocate the array
bool insert(int i); // insert item i at back
bool remove(int &i); // remove front item into i
bool isfull(); // returns true iff the queue is full
bool isempty(); // returns true iff the queue is empty
};
Question 2: file I/O and command line arguments
Write a complete program that expects to receive two command line
arguments (aside from the name of the executable of course).
If the correct number of arguments are supplied, it takes the first
as a filename and the second as a block of text to search for,
opens the file, and counts the
number of times the text appears in the file. For example, in the
line below the text "foo" appears three times:
blah blah foo blahfoo blah blahfooblah
Question 3: exceptions
In your own words, describe how exceptions (try, throw, and catch)
work in C++, and provide a short code example.