The problems below are a few examples of supplied interfaces and problems to be overcome (and here are some potential solutions).
class StrList { public: StrList(); ~StrList(); long getListSize(); bool insertAtBack(string s); bool insertAtFront(string s); bool removeFromBack(string &s); bool removeFromFront(string &s); private: // who cares, we can't access it anyway ;-) }; |
class Queue { public: Queue(); ~Queue(); bool enqueue(string s); bool dequeue(string &s); long getQsize(); private: // who cares, we can't access it anyway ;-) }; |
struct Node { string info; Node *next, *prev; }; |
Suppose you are given the class definition below:
class Queue { public: Queue(); ~Queue(); bool enqueue(string s); bool dequeue(string &s); long getSize(); private: // who cares, we can't access it anyway ;-) }; |
Try to implement a stand-alone function to remove a particular string, s,
from a queue but leave the rest of the organized as before:
bool Remove(Queue &Q, string s);
Try writing a complete C++ program that accepts command line
arguments: printing all the command line arguments a user provided
that begin with the '-' character. For example, if the
user command was
./myprog -r -blah foo
then the program should display "-r" and "-blah".
Try writing a complete C++ program that accepts a filename as a command line argument, tries to open the file for input, counts the total number of lines in the file, counts the total number of whitespace characters in the file, and determines the length of the longest line in the file. (Remember to close the file afterwards.)